-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapp_router.dart
More file actions
86 lines (83 loc) · 2.66 KB
/
app_router.dart
File metadata and controls
86 lines (83 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:tattoo/shells/animated_shell_container.dart';
import 'package:tattoo/screens/main/home_screen.dart';
import 'package:tattoo/screens/main/profile/about_screen.dart';
import 'package:tattoo/screens/main/profile/profile_screen.dart';
import 'package:tattoo/screens/main/score/score_screen.dart';
import 'package:tattoo/screens/main/course_table/course_table_screen.dart';
import 'package:tattoo/screens/welcome/intro_screen.dart';
import 'package:tattoo/screens/welcome/login_screen.dart';
import 'package:tattoo/services/firebase_service.dart';
final rootNavigatorKey = GlobalKey<NavigatorState>();
abstract class AppRoutes {
static const home = '/';
static const score = '/score';
static const profile = '/profile';
static const intro = '/intro';
static const login = '/login';
static const about = '/about';
}
/// Creates a configured [GoRouter] starting at [initialLocation].
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()),
),
],
),
],
),
],
);