replace<T> method

Future<T?> replace<T>(
  1. String location, {
  2. Object? extra,
})

Replaces the top-most page of the page stack with the given one but treats it as the same page.

The page key will be reused. This will preserve the state and not run any page animation.

See also:

  • push which pushes the given location onto the page stack.
  • pushReplacement which replaces the top-most page of the page stack but always uses a new page key.

Implementation

Future<T?> replace<T>(String location, {Object? extra}) {
  log('replace $location');
  return routeInformationProvider.replace<T>(
    location,
    base: routerDelegate.currentConfiguration,
    extra: extra,
  );
}