pushAndRemoveUntil<T extends Object> method

  1. @optionalTypeArgs
Future<T> pushAndRemoveUntil <T extends Object>(BuildContext context, Route<T> newRoute, RoutePredicate predicate)

Push the given route 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 _finishAccountCreation() {
  Navigator.pushAndRemoveUntil(
    context,
    new MaterialPageRoute(builder: (BuildContext context) => new MyHomePage()),
    ModalRoute.withName('/'),
  );
}

Implementation

@optionalTypeArgs
static Future<T> pushAndRemoveUntil<T extends Object>(BuildContext context, Route<T> newRoute, RoutePredicate predicate) {
  return Navigator.of(context).pushAndRemoveUntil<T>(newRoute, predicate);
}