Mangaldeep Pannu
Mangaldeep Pannu

Reputation: 3987

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

Upvotes: 0

Views: 264

Answers (1)

Mangaldeep Pannu
Mangaldeep Pannu

Reputation: 3987

Okay it was simple I just had to set

barrierDismissible: false,

Upvotes: 1

Related Questions