pushNamedAndRemoveUntil<T extends Object> method

  1. @optionalTypeArgs
Future<T> pushNamedAndRemoveUntil <T extends Object>(BuildContext context, String newRouteName, RoutePredicate predicate)
@optionalTypeArgs

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.

Sample code

Typical usage is as follows:

void _resetToCalendar() {
  Navigator.pushNamedAndRemoveUntil(context, '/calendar', ModalRoute.withName('/'));
}

Implementation

@optionalTypeArgs
static Future<T> pushNamedAndRemoveUntil<T extends Object>(BuildContext context, String newRouteName, RoutePredicate predicate) {
  return Navigator.of(context).pushNamedAndRemoveUntil<T>(newRouteName, predicate);
}