$route<T extends ShellRouteData> static method

ShellRoute $route<T extends ShellRouteData>({
  1. required T factory(
    1. GoRouterState
    ),
  2. GlobalKey<NavigatorState>? navigatorKey,
  3. GlobalKey<NavigatorState>? parentNavigatorKey,
  4. List<RouteBase> routes = const <RouteBase>[],
  5. bool notifyRootObserver = true,
  6. List<NavigatorObserver>? observers,
  7. String? restorationScopeId,
})

A helper function used by generated code.

Should not be used directly.

Implementation

static ShellRoute $route<T extends ShellRouteData>({
  required T Function(GoRouterState) factory,
  GlobalKey<NavigatorState>? navigatorKey,
  GlobalKey<NavigatorState>? parentNavigatorKey,
  List<RouteBase> routes = const <RouteBase>[],
  bool notifyRootObserver = true,
  List<NavigatorObserver>? observers,
  String? restorationScopeId,
}) {
  T factoryImpl(GoRouterState state) {
    return (_stateObjectExpando[state] ??= factory(state)) as T;
  }

  FutureOr<String?> redirect(BuildContext context, GoRouterState state) =>
      factoryImpl(state).redirect(context, state);

  Widget builder(BuildContext context, GoRouterState state, Widget navigator) =>
      factoryImpl(state).builder(context, state, navigator);

  Page<void> pageBuilder(BuildContext context, GoRouterState state, Widget navigator) =>
      factoryImpl(state).pageBuilder(context, state, navigator);

  return ShellRoute(
    builder: builder,
    pageBuilder: pageBuilder,
    parentNavigatorKey: parentNavigatorKey,
    routes: routes,
    navigatorKey: navigatorKey,
    notifyRootObserver: notifyRootObserver,
    observers: observers,
    restorationScopeId: restorationScopeId,
    redirect: redirect,
  );
}