如何关闭颤振对话框? [英] How to dismiss flutter dialog?

查看:20
本文介绍了如何关闭颤振对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 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 just Navigator.pop(context, result).

所以我假设这两个中的一个应该做你想做的.

so I'd assume one of these two should do what you want.

这篇关于如何关闭颤振对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆