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

4

4 回答 4

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

于 2021-03-18T16:42:45.427 回答
0

use

Navigator.of(context,rootNavigator:true).pop()
于 2021-03-15T19:18:01.627 回答
0

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

于 2021-03-15T19:30:28.087 回答
0

what I usually use is

Navigator.pop(context);

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

于 2021-03-15T21:59:51.383 回答