对话框在Flutter中关闭

问题描述 投票:0回答:1

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

当数据加载时,我显示的是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个回答
1
投票

好吧,这很简单,我只需要设置

barrierDismissible: false,
© www.soinside.com 2019 - 2024. All rights reserved.