3

strong text Navigator.pushNamedAndRemoveUntil(context, "/tabs", (Route route) => false);

1
  • you can add NavigatorObserver in the MaterialApp widget to listen for the navigations Commented Mar 18, 2020 at 6:15

1 Answer 1

5

If you want to remove all the previous pages navigated from the stack you should use this

Navigator.pushNamedAndRemoveUntil(context, "/tabs", (Route route) => route.isFirst);

Or if you want to pop to a specific page

Navigator.pushNamedAndRemoveUntil(context, "/tabs", (Route route) => route.settings.name == 'homePage'); //replace with where you want to pop to

Then the newly pushed page will become the first page in navigation stack

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.