如何关闭颤振对话框? [英] How to dismiss flutter dialog?
问题描述
我是 Flutter 的新手,我想在任务完成后关闭我的对话框.我试过了:
I am new to flutter, I want to dismiss my dialog after the task completion. I've tried with:
Navigator.pop(context, true);
但是我的屏幕变黑了,对话框还在上面.这是我的对话代码.
But my screen is getting black and dialog is still up there. here is my dialog code.
Dialog _dialog = new Dialog(
child: new Row(
mainAxisSize: MainAsixSize.min,
children: <Widget> [
new CircularProgressIndicator(),
new Text("Loading")]),
);
推荐答案
https://docs.flutter.io/flutter/material/showDialog.html 说
此方法创建的对话路由被推送到根导航器.如果应用程序有多个 Navigator 对象,可能需要调用 Navigator.of(context, rootNavigator: true).pop(result)
来关闭对话框,而只需调用 Navigator.pop(context, 结果)
.
The dialog route created by this method is pushed to the root navigator. If the application has multiple Navigator objects, it may be necessary to call
Navigator.of(context, rootNavigator: true).pop(result)
to close the dialog rather justNavigator.pop(context, result)
.
所以我假设这两个中的一个应该做你想做的.
so I'd assume one of these two should do what you want.
这篇关于如何关闭颤振对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!