File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/// Constant strings representing the names of the routes for easy refactoring.
22class AppRoutes {
33 // Pre-Auth
4- static const String login = '/ login' ;
5- static const String signUp = '/ signup' ;
6- static const String onboarding = '/ onboarding' ;
7- static const String verify = '/ verify' ;
4+ static const String login = 'login' ;
5+ static const String signUp = 'signup' ;
6+ static const String onboarding = 'onboarding' ;
7+ static const String verify = 'verify' ;
88
99 // Post-Auth
10- static const String home = '/ home' ;
10+ static const String home = 'home' ;
1111}
Original file line number Diff line number Diff line change 11import 'package:flutter/material.dart' ;
2+ import 'package:flutter_native_splash/flutter_native_splash.dart' ;
23import 'package:flutter_screenutil/flutter_screenutil.dart' ;
34import 'package:get/get.dart' ;
45import 'package:sentry_flutter/sentry_flutter.dart' ;
@@ -28,7 +29,7 @@ class Codephile extends StatelessWidget {
2829 );
2930 },
3031 debugShowCheckedModeBanner: false ,
31- initialRoute: AppRoutes .onboarding ,
32+ initialRoute: _getInitialRoute () ,
3233 navigatorObservers: < NavigatorObserver > [
3334 SentryNavigatorObserver (),
3435 AppNavigationObserver (),
@@ -46,6 +47,19 @@ class Codephile extends StatelessWidget {
4647 ImageService .init ();
4748 StorageService .init ();
4849
50+ Future .delayed (const Duration (seconds: 1 ), FlutterNativeSplash .remove);
51+
4952 return const Codephile ();
5053 }
54+
55+ String _getInitialRoute () {
56+ if (StorageService .newUser) {
57+ return AppRoutes .onboarding;
58+ } else if (StorageService .user != null &&
59+ StorageService .authToken != null ) {
60+ return AppRoutes .home;
61+ } else {
62+ return AppRoutes .login;
63+ }
64+ }
5165}
Original file line number Diff line number Diff line change 1- import 'package:flutter_native_splash/flutter_native_splash.dart' ;
21import 'package:get/get.dart' ;
32
43import '../../data/constants/routes.dart' ;
54import '../../data/services/local/storage_service.dart' ;
65
76Future <void > decideNextScreen () async {
8- await Future .delayed (const Duration (seconds: 1 ));
97 if (! StorageService .newUser) {
108 if (StorageService .user != null && StorageService .authToken != null ) {
119 Get .offNamed (AppRoutes .home);
1210 } else {
1311 Get .offNamed (AppRoutes .login);
1412 }
1513 }
16- await Future .delayed (const Duration (seconds: 1 ));
17- FlutterNativeSplash .remove ();
1814}
Original file line number Diff line number Diff line change 11import 'package:card_swiper/card_swiper.dart' ;
22import 'package:flutter/material.dart' ;
33
4- import 'decide_next_screen.dart' ;
54import 'widgets/onboarding_widgets.dart' ;
65
76/// The onboarding screen widget.
87class OnboardingScreen extends StatelessWidget {
98 /// The onboarding screen widget.
109 OnboardingScreen ({Key ? key}) : super (key: key) {
1110 _controller = SwiperController ();
12- decideNextScreen ();
1311 }
1412
1513 /// Internal controller for the [Swiper] widget.
You can’t perform that action at this time.
0 commit comments