createAppRouter function
- required String initialLocation,
Creates a configured GoRouter starting at initialLocation.
Implementation
GoRouter createAppRouter({
required String initialLocation,
}) => GoRouter(
navigatorKey: rootNavigatorKey,
initialLocation: initialLocation,
observers: [
if (firebase.analyticsObserver case final observer?) observer,
],
routes: [
GoRoute(
path: AppRoutes.intro,
builder: (context, state) => const IntroScreen(),
),
GoRoute(
path: AppRoutes.login,
builder: (context, state) => const LoginScreen(),
),
GoRoute(
path: AppRoutes.about,
builder: (context, state) => const AboutScreen(),
),
StatefulShellRoute(
builder: (context, state, navigationShell) =>
HomeScreen(navigationShell: navigationShell),
navigatorContainerBuilder: (context, navigationShell, children) {
return AnimatedShellContainer(
currentIndex: navigationShell.currentIndex,
children: children,
);
},
branches: [
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.home,
pageBuilder: (context, state) =>
const NoTransitionPage(child: CourseTableScreen()),
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.score,
pageBuilder: (context, state) =>
const NoTransitionPage(child: ScoreScreen()),
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.profile,
pageBuilder: (context, state) =>
const NoTransitionPage(child: ProfileScreen()),
),
],
),
],
),
],
);