$route<T extends StatefulShellRouteData> static method

StatefulShellRoute $route<T extends StatefulShellRouteData>({
  1. required T factory(
    1. GoRouterState
    ),
  2. required List<StatefulShellBranch> branches,
  3. GlobalKey<NavigatorState>? parentNavigatorKey,
  4. ShellNavigationContainerBuilder? navigatorContainerBuilder,
  5. String? restorationScopeId,
})

A helper function used by generated code.

Should not be used directly.

Implementation

static StatefulShellRoute $route<T extends StatefulShellRouteData>({
  required T Function(GoRouterState) factory,
  required List<StatefulShellBranch> branches,
  GlobalKey<NavigatorState>? parentNavigatorKey,
  ShellNavigationContainerBuilder? navigatorContainerBuilder,
  String? restorationScopeId,
}) {
  T factoryImpl(GoRouterState state) {
    return (_stateObjectExpando[state] ??= factory(state)) as T;
  }

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

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

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

  if (navigatorContainerBuilder != null) {
    return StatefulShellRoute(
      branches: branches,
      builder: builder,
      pageBuilder: pageBuilder,
      navigatorContainerBuilder: navigatorContainerBuilder,
      parentNavigatorKey: parentNavigatorKey,
      restorationScopeId: restorationScopeId,
      redirect: redirect,
    );
  }
  return StatefulShellRoute.indexedStack(
    branches: branches,
    builder: builder,
    pageBuilder: pageBuilder,
    parentNavigatorKey: parentNavigatorKey,
    restorationScopeId: restorationScopeId,
    redirect: redirect,
  );
}