防止对话框在Flutter中因外部触摸而关闭 [英] Prevent dialog from closing on outside touch in Flutter

查看:111
本文介绍了防止对话框在Flutter中因外部触摸而关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Flutter中,我在异步任务期间为加载程序编写了一个简单对话框。当我触摸外部对话框时,我该如何阻止这种行为?

In Flutter i write simple dialog for loader during async task. when i touch outside dialog dismissed, How can I stop this behaviour ?

代码

  showDialog(
    context: context,
    builder: (_) => new Dialog(
          child: new Container(
            alignment: FractionalOffset.center,
            height: 80.0,
            padding: const EdgeInsets.all(20.0),
            child: new Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                new CircularProgressIndicator(),
                new Padding(
                  padding: new EdgeInsets.only(left: 10.0),
                  child: new Text("Loading"),
                ),
              ],
            ),
          ),
        ));

任何帮助将不胜感激,谢谢您。

Any help will be appreciated, thank you in advance.

推荐答案

有一个名为 barrierDismissible 的属性,您可以将其传递给 showDialog ;

There's a property called barrierDismissible that you can pass to showDialog ; which makes dialogs dismissible or not on external click

showDialog(
  barrierDismissible: false,
  builder: ...
)

这篇关于防止对话框在Flutter中因外部触摸而关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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