摇动“ showDialog”与Navigator.pop() [英] Flutter "showDialog" with Navigator.pop()
本文介绍了摇动“ showDialog”与Navigator.pop()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在使用showDialog时遇到问题,当我按任何按钮时都无反应,但是如果我使用 Navigator.pushNamed(context, / screen1)
,它将起作用。我无法运行 Navigator.pop(context)
,它不会返回任何错误。
I have problem with showDialog, when i press nothing happens but if i use Navigator.pushNamed(context, "/screen1")
it works. I can not run Navigator.pop(context)
, it does not return any errors.
_showDialog(BuildContext context) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: new Text("Alert Dialog title"),
actions: <Widget>[
new FlatButton(
child: new Text("Back"),
onPressed: () {
//Navigator.pushNamed(context, "/screen1");
Navigator.pop(context);
},
),
],
);
});}
在我的build()中:
In my build() :
IconButton(
iconSize: 30.0,
onPressed: () => _showDialog(context),
icon: Icon(
Icons.clear,
color: Colors.white,
),
)
推荐答案
尝试调用 Navigator.of(cont ext).pop();
而不是 Navigator.pop(context);
这篇关于摇动“ showDialog”与Navigator.pop()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文