android - 如何在颤动中从网页视图返回?
问题描述
单击按钮后,它应该显示 Web 视图。我这样做了。但是当按下后退按钮时,它正在关闭应用程序。它不会回到以前的状态。如果我按下后退按钮,它应该返回上一页或状态。我正在从一个函数中获取 web 视图。这是我的代码:
_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),
);
推荐阅读
- r - 绘制 2 x 变量 R plotly 条形图
- mysql - 如何避免在将数据从 csv 文件导入 MySQL 表时创建空格
- html - 如何阻止我的标题在我的整个网站页面中向下滚动
- ios - Firebase 函数在 swift func 中返回文档结果
- python-3.x - 这个“.__class__.name__”是如何工作的?
- android - 是否有适用于 Android 的 GOOGLE DOCS API
- sql - SQL 更改属性集
- arrays - 尝试在 ruby 中复制然后旋转数组 - 为 nil:NilClass (NoMethodError) 获取错误未定义方法“[]”
- bash - BASH 脚本:如何替换文件路径字符串中的字符串?
- python - 我无法在 PyGame 中正确跟踪 KEYDOWN 事件