如何消除抖动对话框? [英] How to dismiss flutter dialog?

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

问题描述

我是新手,我想在任务完成后关闭对话框。我尝试过:

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(上下文,结果)

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天全站免登陆