File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1-
1+ /// Constant strings representing the names of the routes for easy refactoring.
2+ class AppRoutes {
3+ static const String splash = '/' ;
4+ static const String login = '/login' ;
5+ static const String home = '/home' ;
6+ }
Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ Future<void> _initFirebase() async {
5353 final notification = message.notification;
5454 if (notification != null ) {
5555 debugPrint (
56- 'title: ${notification .title } \t body: ${notification .body }' );
56+ 'title: ${notification .title } \t body: ${notification .body }' ,
57+ );
5758 }
5859 },
5960 );
Original file line number Diff line number Diff line change 11import 'package:flutter/material.dart' ;
2+ import 'package:get/get.dart' ;
3+ import 'package:sentry_flutter/sentry_flutter.dart' ;
4+
5+ import 'router.dart' ;
26
37class Codephile extends StatelessWidget {
48 const Codephile ({Key ? key}) : super (key: key);
59
610 @override
711 Widget build (BuildContext context) {
8- return const MaterialApp (
12+ return GetMaterialApp (
913 debugShowCheckedModeBanner: false ,
14+ // home: const SplashScreen(),
15+ navigatorObservers: < NavigatorObserver > [
16+ SentryNavigatorObserver (),
17+ ],
18+ onGenerateRoute: AppRouter .generateRoute,
19+ title: 'Codephile' ,
1020 );
1121 }
1222
Original file line number Diff line number Diff line change 1+ import 'package:flutter/material.dart' ;
2+ import 'package:get/get.dart' ;
13
4+ import '../../data/constants/routes.dart' ;
5+
6+ /// Wrapper for a single method to be passed to [GetMaterialApp.onGenerateRoute] .
7+ class AppRouter {
8+ static Route <dynamic > generateRoute (RouteSettings settings) {
9+ switch (settings.name) {
10+ case AppRoutes .splash:
11+ return GetPageRoute (
12+ // page: () => const SplashScreen(),
13+ routeName: settings.name,
14+ settings: settings,
15+ );
16+ case AppRoutes .home:
17+ return GetPageRoute (
18+ // page: () => const HomeScreen(),
19+ routeName: settings.name,
20+ settings: settings,
21+ );
22+ case AppRoutes .login:
23+ return GetPageRoute (
24+ // page: () => const LoginScreen(),
25+ routeName: settings.name,
26+ settings: settings,
27+ );
28+ default :
29+ return GetPageRoute (
30+ page: () => Scaffold (
31+ body: Center (
32+ child: Text (
33+ 'No route defined for '
34+ '${settings .name }' ,
35+ ),
36+ ),
37+ ),
38+ routeName: '/undefined' ,
39+ settings: settings,
40+ );
41+ }
42+ }
43+ }
Original file line number Diff line number Diff line change @@ -324,6 +324,13 @@ packages:
324324 url: "https://pub.dartlang.org"
325325 source: hosted
326326 version: "2.1.2"
327+ get:
328+ dependency: "direct main"
329+ description:
330+ name: get
331+ url: "https://pub.dartlang.org"
332+ source: hosted
333+ version: "4.6.1"
327334 glob:
328335 dependency: transitive
329336 description:
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ dependencies:
1717 sdk : flutter
1818 flutter_bloc : ^8.0.1
1919 freezed_annotation : ^1.1.0
20+ get : ^4.6.1
2021 hive_flutter : ^1.1.0
2122 hydrated_bloc : ^8.0.0
2223 json_annotation : ^4.4.0
You can’t perform that action at this time.
0 commit comments