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

void pushReplacementRoute<T extends Object?, TO extends Object?>(
  1. Widget route, {
  2. RouteSettings? settings,
  3. bool maintainState = true,
  4. bool fullscreenDialog = false,
  5. bool allowSnapshotting = true,
  6. TO? result,
})

Replaces the current route with a new route widget.

The route parameter specifies the widget for the new route to push. The settings parameter can be used to customize the route settings. The maintainState parameter determines whether the state of the new route should be preserved. The fullscreenDialog parameter specifies whether the new route is a fullscreen dialog. The allowSnapshotting parameter determines whether the route can be snapshot or not. The result parameter can be used to return a value from the new route.

Implementation

void pushReplacementRoute<T extends Object?, TO extends Object?>(
  Widget route, {
  RouteSettings? settings,
  bool maintainState = true,
  bool fullscreenDialog = false,
  bool allowSnapshotting = true,
  TO? result,
}) {
  Navigator.of(this).pushReplacement<T, TO>(
    MaterialPageRoute<T>(
      builder: (context) => route,
      settings: settings,
      maintainState: maintainState,
      fullscreenDialog: fullscreenDialog,
      allowSnapshotting: allowSnapshotting,
    ),
    result: result,
  );
}