I\'m new to flutter development, and find it a bit frustrating in iOS when you have a navigation drawer and when you swipe to open it, it\'ll perform a Navigation.of(c
I am not quite sure what you want to achieve, but most of the time when people want to get rid of the back functionality, because they don't wanna enable the user to control the auth mechanism. For example after the users log in, you don't want them to navigate to the Login page by just press on the back button(or swipe back in iOS). A potential solution is, using pushNamedAndRemoveUntil
.
Future<T> pushNamedAndRemoveUntil<T extends Object>(BuildContext context, String newRouteName, RoutePredicate predicate)
Push the route with the given name onto the navigator that most tightly encloses the given context, and then remove all the previous routes until the
predicate
returns true.
Example code:
pushNamedAndRemoveUntil(context, '/home', ModalRoute.withName('/home'));
Note: use this method to some certain extent, because you might mess up your navigation history.