0

I have an AlertDialog with 1 button. Although I have set the barrierDismissable set to false, in iOS, the dialog can be still dismissed when the user clicked outside of the box.

I can accept either:

  • When the user clicked outside the box is there a method to detect and call a specific function code?
  • Prevent barrierDismissable issue in iOS

My code is as below:

Future<void> dialogNotifyUser(BuildContext context) {
    return showDialog<void>(
      context: context,
      barrierDismissible: false,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('Title'),
          content: Text('Body'),
          actions: <Widget>[
            FlatButton(
              child: Text('Ok'),
              onPressed: () {
                Navigator.of(context).pop();
                ..... code
              },
            ),
          ],
        );
      },
    );
  }

Is this a common issue, else I might use a 3rd party library or code an alert widget myself.

Calvin
  • 321
  • 2
  • 16

1 Answers1

0

Try calling Navigator.of(context).pop(); instead of Navigator.pop(context);

Original answer in link below Flutter "showDialog" with Navigator.pop()

Wali Khan
  • 586
  • 1
  • 5
  • 13
  • Thanks for the response, however, I am already using Navigator.of(context).pop() in the code above – Calvin Aug 16 '20 at 17:10