运行WebViewScaffold时获取_CompileTimeError

时间:2019-04-22 16:38:26

标签: dart flutter

我正在开发一个flutter项目,该项目显示选定新闻的详细信息并使用其源信息的url,我想使用WebViewScaffold在我的flutter应用程序中显示该网站。这是我的newsdetail.dart页面:

class NewsDetailPage extends StatefulWidget {
  final MainModel model;

  NewsDetailPage(this.model);

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _NewsDetailPageState();
  }
}

class _NewsDetailPageState extends State<NewsDetailPage> {
  void _opennewpage() {
    Navigator.pushNamed(context, '/webview');
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
          onWillPop: () {
            print('back button presses');
            Navigator.pop(context, false);
            return Future.value(false);
          },
          child: ScopedModelDescendant<MainModel>(
              builder: (BuildContext context, Widget child, MainModel model) {
            final News news = model.allnews[model.selectedIndex];
//selected news.

            return Scaffold(
              appBar: AppBar(
                title: Text(news.title),
              ),
              body: Column(
                children: <Widget>[
                  Container(
                    padding: EdgeInsets.all(20.0),
                    child: Text(
                      news.description,
                      style: TextStyle(
                        fontSize: 20.0,
                      ),
                    ),
                  ),
                  Center(
                    child: FlatButton(
                      onPressed: () {
                        model.setUrl(news.url);
                        _opennewpage();
                      },
                      child: Text('further details'),
                    ),
                  ),
                ],
              ),
            );
          }),
        );

  }
}

我正在将scopped_models用于我的所有吸气剂和功能。单击一个Flatbutton时,我首先在带有news.url(model.setUrl(news.url);)的scoped_models文件夹中设置一个名为“ selectedUrl”的变量,然后执行_opennewpage函数(如上面的代码片段所示) ,将我导航到“ / webview”网址。 在main.dart文件中的路由中,这就是我定义“ / webview”的方式

routes: {
   "/webview": (_) => WebviewScaffold(
                resizeToAvoidBottomInset: true,
                url: _model.selectedUrl,
                appBar: new AppBar(
                  title: const Text('Widget Webview'),
                ),
                withZoom: false,
                withLocalStorage: true,
              ),
}

_model.selectedUrl就是一个吸气剂,它从Scopped_models文件夹中返回“ selectedUrl”的值,我已经通过打印检查了_model.selectedUrl的值,并且显示了一个完美的工作URL和错误。

我在pubspec.yaml文件中安装了flutter_webview_plugin:^ 0.3.4。 但是当我运行此代码并单击调用_opennewpage函数的Flatbuttom时,出现此错误:

I/flutter ( 9344): The following _CompileTimeError was thrown building WebviewScaffold(dirty, state:
I/flutter ( 9344): _WebviewScaffoldState#0a52c):
I/flutter ( 9344): 'package:flutter_webview_plugin/src/webview_scaffold.dart': error:
I/flutter ( 9344): file:///home/saurabh/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.4/lib/src/webview_scaffold.dart:110:7:
I/flutter ( 9344): Error: No named parameter with the name 'resizeToAvoidBottomInset'.
I/flutter ( 9344):       resizeToAvoidBottomInset: widget.resizeToAvoidBottomInset,
I/flutter ( 9344):       ^^^^^^^^^^^^^^^^^^^^^^^^

0 个答案:

没有答案