简体   繁体   中英

Dialog Box closes in Flutter

I have a Update Button by clicking on which data loads in background.

When the data loads I am displaying AlertDialog which closes automatically when the data gets loaded.

However while the data is loading and if the user clicks somewhere else on screen the Dialog Box closes which is undesirable.

The question is How can I prevent DialogBox to close?

 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),
       ),
     );
   },
 );
} 

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

barrierDismissible: false,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM