I built an AlertDialog to display Loading while i'm authenticating the user and when it finishes i pop it.
Widget loadingDialog = new AlertDialog( content: new Row( children: <Widget>[ new CircularProgressIndicator(), Padding( padding: const EdgeInsets.only(left: 8.0), child: new Text("Loading..."), ), ], ),);
But, if the user taps outside the Dialog it closes. So when the auth finishes, it will still pop something (i guess the scaffol), breaking the app. How can i make Dialog not closable?
How do I stop dialog close on click outside Flutter? To prevent the dialog from closing on outside barrier touch, you have to set barrierDismissible to false. It is true by default.
Set the onClickListener during the creation of the dialog to null. Then set a onClickListener after the dialog is shown.
You can use dialog. setCanceledOnTouchOutside(true); which will close the dialog if you touch outside of the dialog. Window window = this.
AlertDialog generally consists of the main title, the message, and two buttons, technically termed as a positive button and a negative button. Both positive and negative buttons can be programmed to perform various actions. By default, the negative button lets close the AlertDialog without any additional lines of code.
There is a property inside showDialog
called barrierDismissible
. Setting this value to false will make your AlertDialog not closable by clicking outside.
showDialog( ... barrierDismissible: false, ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With