pushReplacement<T extends Object, TO extends Object> method

  1. @optionalTypeArgs
Future<T> pushReplacement <T extends Object, TO extends Object>(BuildContext context, Route<T> newRoute, { TO result })

Replace the current route of the navigator that most tightly encloses the given context by pushing the given route and then disposing the previous route once the new route has finished animating in.

Sample code

Typical usage is as follows:

void _completeLogin() {
  Navigator.pushReplacement(context, new MaterialPageRoute(builder: (BuildContext context) => new MyHomePage()));
}

Implementation

@optionalTypeArgs
static Future<T> pushReplacement<T extends Object, TO extends Object>(BuildContext context, Route<T> newRoute, { TO result }) {
  return Navigator.of(context).pushReplacement<T, TO>(newRoute, result: result);
}