0

i have a problem in the ios version of my app, this is the code.

void showErrorAlert(BuildContext context, String msj) {
  showDialog(
    context: context,
    builder: (context) {
      return AlertDialog(
        title: Text('Error'),
        content: Text(msj),
        actions: [
          TextButton(
            onPressed: () => Navigator.of(context).pop(),
            child: Text('ok'),
          )
        ],
      );
    },
  );
}

the Navigator.of(context).pop() in android works perfect, close the dialog and everything is ok, but in ios, the full app is closed when that code is called 'Navigator.of(context).pop()', someone know what can i do to close only the dialog in ios?

P.D.: i dont have any error or warning in the output console, even when te app get closed P.D.2: i already tried change the .pop to this 'Navigator.of(context, rootNavigator: true).pop('dialog')' but it doesnt work

double-beep
  • 5,031
  • 17
  • 33
  • 41

4 Answers4

2

Try switching to the stable branch because it is a reported bug. Use

flutter channel stable

EDIT

Damn it this answer got saved as a draft and I closed my laptop. I just realized you had already solved it

Siddharth Agrawal
  • 2,960
  • 3
  • 16
  • 37
0

use

Navigator.of(context,rootNavigator:true).pop()
Biruk Telelew
  • 1,161
  • 7
  • 13
0

SystemNavigator.pop() is the recommended way to exit your app.

Andrej
  • 2,743
  • 2
  • 11
  • 28
0

what I usually use is

Navigator.pop(context);

and it works fine for me. Had a similar issue when adding .pop()

Yusuf-Uluc
  • 887
  • 4
  • 15