【问题标题】:Dialog Box closes in Flutter对话框在 Flutter 中关闭
【发布时间】:2019-04-17 15:36:15
【问题描述】:

我有一个更新按钮,通过点击在后台加载的数据。

加载数据时,我会显示 AlertDialog,它会在加载数据时自动关闭。

但是,当数据正在加载时,如果用户单击屏幕上的其他位置,则对话框会关闭,这是不希望的。

问题是如何防止对话框关闭?

 Future<void> _loadingDialog(String title) async {
 return showDialog(
   context: context,
   barrierDismissible: true,
   builder: (context) {
     return AlertDialog(
       title: Text(title),
       content: LinearProgressIndicator(
         backgroundColor: colorPrimaryLight,
         valueColor: AlwaysStoppedAnimation<Color>(colorPrimaryDark),
       ),
     );
   },
 );
} 

【问题讨论】:

    标签: dart flutter flutter-layout


    【解决方案1】:

    好的,很简单,我只需要设置

    barrierDismissible: false,
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-31
      • 2022-01-22
      • 2020-03-13
      • 1970-01-01
      • 2011-02-25
      • 2020-12-29
      • 1970-01-01
      相关资源
      最近更新 更多