pushReplacement method

void pushReplacement(
  1. Route route, {
  2. String? name,
})

Pops the current route and puts a new route on top of the navigation stack.

The route may also be given a name, in which case it will be cached in the routes map under this name (if there was already a route with the same name, it will be overwritten).

The method calls Route.didPush for this new route after it is added and also calls the Route.didPop callback for the popped route.

Implementation

void pushReplacement(Route route, {String? name}) {
  pushRoute(route, name: name, replace: true);
}