pushNamed<T> method

Future<T?> pushNamed<T>(
  1. String routeName, {
  2. Object? arguments,
})

Pushes a named route onto the navigation stack.

The route is created from the Navigator.routes map or Navigator.onGenerateRoute factory.

Implementation

Future<T?> pushNamed<T>(String routeName, {Object? arguments}) {
  final settings = RouteSettings(name: routeName, arguments: arguments);
  final route = _createRoute(settings);
  if (route == null) {
    throw StateError(
      'Navigator.pushNamed called with a route name that could not be '
      'resolved: "$routeName".',
    );
  }
  return push<T>(route as Route<T>);
}