$route<T extends StatefulShellRouteData> static method
StatefulShellRoute
$route<T extends StatefulShellRouteData>({
- required T factory(),
- required List<
StatefulShellBranch> branches, - 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,
);
}