strong text Navigator.pushNamedAndRemoveUntil(context, "/tabs", (Route route) => false);
1 Answer
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
NavigatorObserver
in theMaterialApp
widget to listen for the navigations