My page have some api request, when api return error, I will show the dialog.
When I click the confirm button, the dialog should be dismiss and current page will finish.
var count = 0;
Navigator.popUntil(context, (route) {
return count++ == 2;
});
but sometimes it works sometimes it not work.(When I reopen this page)
I also tried
Navigator.of(context, rootNavigator: true).pop();
Navigator.pop(context);//pop dialog
Navigator.pop(context);//pop current page
Navigator.of(context).pop();
All of the above is sometimes works sometimes not work.
Why it is so unstable? And what is the correct way to handle dialog and page navigate?
2
Answers
this works based on the case you mentioned, however, you also need to check the behavior of your page which might have a difference stack flow.
The page pop action should depends on the dialog pop action