flutter flutter_webview_plugin始终加载

时间:2018-07-06 03:15:44

标签: webview flutter

我在ios模拟器中运行代码,但ios始终加载,webview状态为startLoad,但无法完成finishLoad, 页面始终加载,代码如下:

@override
Widget build(BuildContext context) {
List<Widget> titleContent = [];
titleContent.add(new Text(
  "资讯详情",
  style: new TextStyle(color: Colors.white),
));
if (!loaded) {
  titleContent.add(new CupertinoActivityIndicator());
}
titleContent.add(new Container(width: 50.0));
print(widget.id);
return new WebviewScaffold(
  url: "http://www.baidu.com",
  appBar: new AppBar(
    title: new Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: titleContent,
    ),
    actions: <Widget>[
      new IconButton(
        icon: icon,
        onPressed: () {
          print('收藏');
          setState(() {
            icon = new Icon(Icons.star);
          });
        },
      ),
      new IconButton(
        icon: new Icon(Icons.share),
        onPressed: () {
          print('分享');
        },
      ),
    ],
    iconTheme: new IconThemeData(color: Colors.white),
  ),
  withZoom: false,
  withLocalStorage: false,
  withJavascript: true,
  withLocalUrl: true,
);

}

页面如下: the page like this

谢谢

2 个答案:

答案 0 :(得分:1)

收听httpError流。也许您会遇到一些错误,因为它通常可以正常工作。

FlutterWebviewPlugin().onHttpError.listen((WebViewHttpError item) {
  print("   WebView    onHttpError.code: ${item.code}");
});

答案 1 :(得分:0)

尝试删除此行:

withLocalUrl: true,