pushReplacement<T extends Object?, TO extends Object?> method

Future<T?> pushReplacement<T extends Object?, TO extends Object?>(
  1. Widget page, {
  2. Object? arguments,
  3. bool maintainState = true,
  4. bool fullscreenDialog = false,
  5. Transition? transition,
  6. Duration transitionDuration = const Duration(milliseconds: 300),
  7. bool backGestureEnabled = false,
  8. TO? result,
})

Replace the current page of the navigator by pushing the given page and then disposing the previous route once the new route has finished animating in.

transitionDuration will be Duration.zero when transition is equals to Transition.none

backGestureEnabled ignored when transition is Transition.material or Transition.cupertino

Implementation

Future<T?> pushReplacement<T extends Object?, TO extends Object?>(
  Widget page, {
  Object? arguments,
  bool maintainState = true,
  bool fullscreenDialog = false,
  Transition? transition,
  Duration transitionDuration = const Duration(milliseconds: 300),
  bool backGestureEnabled = false,
  TO? result,
}) {
  _validateRouterState();
  return _navigator.pushReplacement<T, TO>(
    page,
    arguments: arguments,
    maintainState: maintainState,
    fullscreenDialog: fullscreenDialog,
    transition: transition,
    transitionDuration: transitionDuration,
    backGestureEnabled: backGestureEnabled,
    result: result,
  );
}