android - 如何在 flutter 中从 web view 返回?

标签 android webview dart flutter

点击按钮后,它应该显示 WebView 。我这样做了。但是当按下后退按钮时,它正在关闭应用程序。它不会回到以前的状态。如果我按下后退按钮,它应该返回到上一页或状态。我正在从一个函数中获取 Web View 。 这是我的代码:

_contentSearch(BuildContext context){
   url = "https://www.google.com";
   return WebviewScaffold(
      url: url,
      appBar: AppBar(
        title: Text("Google"),
      ),
      withJavascript: true,
      withLocalStorage: true,
      withZoom: false,
      enableAppScheme: true,
    )
  },
 );
}

我这样调用这个方法:

 FlatButton(
        padding: EdgeInsets.all(0.0),
        onPressed: (){
          Navigator.pushReplacement(
              context,
              new MaterialPageRoute(builder: (BuildContext context) => _contentSearch(context)
              ));
        },
       child: new Text("Button"),
    ),

回不去了。它总是关闭应用程序。

最佳答案

是因为你用的是pushReplacement(替换导航器的当前路径)而不是push

Navigator.push(
        context,
        MaterialPageRoute(builder: (context) => _contentSearch(context),
      );

关于android - 如何在 flutter 中从 web view 返回?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53570882/

相关文章:

Android:如何在Tabview中显示Webview?

android - 有没有更好的方法来刷新 WebView?

dart - 如何使用 Polymer 绘制卡片/元素网格?

android - 具有百分比空白空间的 LinearLayout

android - 如何在android中通过指定的Pincode获取位置/城镇和州?

android - 如何检查android中所有正在运行的服务?

flutter - 如何设计像给定图像一样的瓷砖?

java - Date date = calendar.getTime() 返回过去的日期

xcode - WebView - 无法在(NSWindow)上设置(contentViewController)用户定义的检查属性

xml - Dart:regexp解析多行xml文档