push<T extends Object?> method

Future<T?> push<T extends Object?>(
  1. Widget screen, {
  2. RouteSettings? settings,
  3. bool maintainState = true,
  4. bool fullscreenDialog = false,
  5. bool rootNavigator = false,
})

Pushes a new screen onto the navigator.

Allows customization of the route via settings, maintainState, and fullscreenDialog. rootNavigator determines whether to push the route onto the root navigator or the nearest Navigator ancestor.

Returns a Future that completes with the result of the pushed route when it is popped.

Implementation

Future<T?> push<T extends Object?>(
  Widget screen, {
  RouteSettings? settings,
  bool maintainState = true,
  bool fullscreenDialog = false,
  bool rootNavigator = false,
}) async =>
    await Navigator.of(
      this,
      rootNavigator: rootNavigator,
    ).push(MaterialPageRoute(
      builder: (_) => screen,
      settings: settings,
      maintainState: maintainState,
      fullscreenDialog: fullscreenDialog,
    ));