Prevent dialog from closing on outside touch in Flutter

Question

Asked by Magesh P on June 01, 2018 (source).

In Flutter i write simple dialog for loader during async task. when i touch outside dialog dismissed, How can I stop this behaviour ?

Code

  showDialog(
    context: context,
    builder: (_) => new Dialog(
          child: new Container(
            alignment: FractionalOffset.center,
            height: 80.0,
            padding: const EdgeInsets.all(20.0),
            child: new Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                new CircularProgressIndicator(),
                new Padding(
                  padding: new EdgeInsets.only(left: 10.0),
                  child: new Text("Loading"),
                ),
              ],
            ),
          ),
        ));

Any help will be appreciated, thank you in advance.

Answer

Question answered by Rémi R (source).

There's a property called barrierDismissible that you can pass to showDialog ; which makes dialogs dismissible or not on external click

showDialog(
  barrierDismissible: false,
  builder: ...
)
ANDROID DART DIALOG FLUTTER IOS
SHARE: