In the following code, I’m defining a StatefulShellRoute with branches:
@TypedStatefulShellRoute<AppShellRouteData>(branches: [
TypedStatefulShellBranch(
routes: [
TypedGoRoute<HomeScreenRoute>(path: '/'),
],
),
TypedStatefulShellBranch(
routes: [
TypedGoRoute<ScheduleScreenRoute>(path: '/schedule'),
],
),
TypedStatefulShellBranch(
routes: [
TypedGoRoute<JobsScreenRoute>(path: '/jobs', routes: [
TypedGoRoute<JobScreenRoute>(path: 'job', name: 'job'),
]),
],
),
TypedStatefulShellBranch(
routes: [
TypedGoRoute<SettingsScreenRoute>(path: '/settings'),
],
),
])
class AppShellRouteData extends StatefulShellRouteData {
@override
Widget builder(BuildContext context, GoRouterState state,
StatefulNavigationShell navigationShell) {
return ScaffoldWithNestedNavigation(navigationShell: navigationShell);
}
}
I’m using AppShellRouteData to wrap the shell with ScaffoldWithNestedNavigation. The problem is that in the generated file, an extension on AppShellRouteData initialized AppShellRouteData as a constant which throws an error.
extension $AppShellRouteDataExtension on AppShellRouteData {
static AppShellRouteData _fromState(GoRouterState state) =>
const AppShellRouteData();
}
How do I fix this?
I have tried defining the extension on my router file without the const expecting it to just replicate it on the generated file.