replace<T extends Object?> method

  1. @optionalTypeArgs
Future<T?> replace<T extends Object?>(
  1. PageRouteInfo route, {
  2. OnNavigationFailure? onFailure,
})

Removes last entry in stack and pushes given route if last entry == route page will just be updated

if onFailure callback is provided, navigation errors will be passed to it otherwise they'll be thrown

Implementation

@optionalTypeArgs
Future<T?> replace<T extends Object?>(
  PageRouteInfo route, {
  OnNavigationFailure? onFailure,
}) {
  final scope = _findStackScope(route);
  scope._removeLast(notify: false);
  markUrlStateForReplace();
  return scope._push<T>(route, onFailure: onFailure);
}