我正在尝试在 webview 中打开一个网页,但在 Flutter WebViewScaffold 小部件中使用动态 url。
WebviewScaffold(
url: "https://www.svstepaper.com/api/web-view/$api_token/$device_id/$getDate/$getPage?",
withJavascript: true,
// run javascript
withZoom: true,
hidden: true,
clearCache: true,
clearCookies: true,
displayZoomControls: true,
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
onTap: (int index) {
setState(() {
print(index);
if (index == 0) {
flutterWebviewPlugin.goBack();
} else if (index == 1) {
flutterWebviewPlugin.reload();
} else if (index == 2) {
flutterWebviewPlugin.goForward();
}
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.arrow_back),
title: Text('Back'),
),
BottomNavigationBarItem(
icon: Icon(Icons.refresh),
title: Text('Refresh'),
),
BottomNavigationBarItem(
icon: Icon(Icons.arrow_forward),
title: Text('Forword'),
),
],
),
initialChild: Container(
// but if you want to add your own waiting widget just add InitialChild
color: Colors.white,
child: const Center(
child: Text('waiting...'),
),
),
)
我的网址是“ https://www.svstepaper.com/api/web-view/$api_token/$device_id/$getDate/$getPage ?” 我将令牌、设备 ID、日期和页码作为参数传递。
正如我从调试中看到的那样,该 URL 是正确的。当我将 url 从调试控制台复制并粘贴到浏览器时,它会正确打开,但不会在 WebView 内打开(给出 404 not found 错误)。
这里有什么问题?