@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22import 'package:flutter/services.dart' ;
33import 'package:flutter_riverpod/flutter_riverpod.dart' ;
44import 'package:threebotlogin/helpers/globals.dart' ;
5+ import 'package:threebotlogin/screens/app_lifecycle_observer.dart' ;
56import 'package:threebotlogin/screens/splash_screen.dart' ;
67import 'package:threebotlogin/services/shared_preference_service.dart' ;
78import 'package:google_fonts/google_fonts.dart' ;
@@ -29,6 +30,11 @@ extension ColorSchemeExtension on ColorScheme {
2930 : const Color .fromARGB (255 , 10 , 10 , 10 );
3031}
3132
33+ final GlobalKey <NavigatorState > navigatorKey = GlobalKey <NavigatorState >();
34+
35+ final lastPausedProvider =
36+ StateProvider <int >((ref) => DateTime .now ().millisecondsSinceEpoch);
37+
3238Future <void > main () async {
3339 WidgetsFlutterBinding .ensureInitialized ();
3440 SystemChrome .setPreferredOrientations ([DeviceOrientation .portraitUp]);
@@ -83,60 +89,65 @@ class MyApp extends ConsumerWidget {
8389 Theme .of (context).textTheme,
8490 );
8591
86- return MaterialApp (
87- theme: ThemeData ().copyWith (
88- colorScheme: kColorScheme,
89- brightness: Brightness .light,
90- textTheme: textTheme,
91- appBarTheme: const AppBarTheme ().copyWith (
92- backgroundColor: kColorScheme.primary,
93- foregroundColor: kColorScheme.onPrimary,
94- ),
95- cardTheme: const CardTheme ().copyWith (
96- color: kColorScheme.surfaceContainer,
97- margin: const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 )),
98- elevatedButtonTheme: ElevatedButtonThemeData (
99- style: ElevatedButton .styleFrom (
100- shape: RoundedRectangleBorder (
101- borderRadius: BorderRadius .circular (5 )),
102- backgroundColor: kColorScheme.primaryContainer),
103- ),
104- expansionTileTheme: const ExpansionTileThemeData ().copyWith (
105- backgroundColor: kColorScheme.backgroundDarker,
106- collapsedBackgroundColor: ThemeData ().colorScheme.surface),
107- bottomNavigationBarTheme: const BottomNavigationBarThemeData ().copyWith (
108- selectedItemColor: kColorScheme.primary,
109- unselectedItemColor: kColorScheme.secondary,
110- ),
111- ),
112- darkTheme: ThemeData (
113- useMaterial3: true ,
114- colorScheme: kDarkColorScheme,
115- brightness: Brightness .dark,
116- textTheme: textTheme,
117- appBarTheme: const AppBarTheme ().copyWith (
118- backgroundColor: kDarkColorScheme.primaryContainer,
119- foregroundColor: kDarkColorScheme.onPrimaryContainer,
120- ),
121- cardTheme: const CardTheme ().copyWith (
122- color: kDarkColorScheme.surfaceContainer,
123- margin: const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 )),
124- elevatedButtonTheme: ElevatedButtonThemeData (
125- style: ElevatedButton .styleFrom (
126- shape: RoundedRectangleBorder (
127- borderRadius: BorderRadius .circular (5 )),
128- backgroundColor: kDarkColorScheme.primaryContainer),
92+ return AppLifecycleObserver (
93+ child: MaterialApp (
94+ navigatorKey: navigatorKey,
95+ theme: ThemeData ().copyWith (
96+ colorScheme: kColorScheme,
97+ brightness: Brightness .light,
98+ textTheme: textTheme,
99+ appBarTheme: const AppBarTheme ().copyWith (
100+ backgroundColor: kColorScheme.primary,
101+ foregroundColor: kColorScheme.onPrimary,
102+ ),
103+ cardTheme: const CardTheme ().copyWith (
104+ color: kColorScheme.surfaceContainer,
105+ margin: const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 )),
106+ elevatedButtonTheme: ElevatedButtonThemeData (
107+ style: ElevatedButton .styleFrom (
108+ shape: RoundedRectangleBorder (
109+ borderRadius: BorderRadius .circular (5 )),
110+ backgroundColor: kColorScheme.primaryContainer),
111+ ),
112+ expansionTileTheme: const ExpansionTileThemeData ().copyWith (
113+ backgroundColor: kColorScheme.backgroundDarker,
114+ collapsedBackgroundColor: ThemeData ().colorScheme.surface),
115+ bottomNavigationBarTheme:
116+ const BottomNavigationBarThemeData ().copyWith (
117+ selectedItemColor: kColorScheme.primary,
118+ unselectedItemColor: kColorScheme.secondary,
119+ ),
129120 ),
130- expansionTileTheme: const ExpansionTileThemeData ().copyWith (
131- backgroundColor: kDarkColorScheme.backgroundDarker,
132- collapsedBackgroundColor: kDarkColorScheme.surface),
133- bottomNavigationBarTheme: const BottomNavigationBarThemeData ().copyWith (
134- selectedItemColor: kDarkColorScheme.primary,
135- unselectedItemColor: kDarkColorScheme.secondary,
121+ darkTheme: ThemeData (
122+ useMaterial3: true ,
123+ colorScheme: kDarkColorScheme,
124+ brightness: Brightness .dark,
125+ textTheme: textTheme,
126+ appBarTheme: const AppBarTheme ().copyWith (
127+ backgroundColor: kDarkColorScheme.primaryContainer,
128+ foregroundColor: kDarkColorScheme.onPrimaryContainer,
129+ ),
130+ cardTheme: const CardTheme ().copyWith (
131+ color: kDarkColorScheme.surfaceContainer,
132+ margin: const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 )),
133+ elevatedButtonTheme: ElevatedButtonThemeData (
134+ style: ElevatedButton .styleFrom (
135+ shape: RoundedRectangleBorder (
136+ borderRadius: BorderRadius .circular (5 )),
137+ backgroundColor: kDarkColorScheme.primaryContainer),
138+ ),
139+ expansionTileTheme: const ExpansionTileThemeData ().copyWith (
140+ backgroundColor: kDarkColorScheme.backgroundDarker,
141+ collapsedBackgroundColor: kDarkColorScheme.surface),
142+ bottomNavigationBarTheme:
143+ const BottomNavigationBarThemeData ().copyWith (
144+ selectedItemColor: kDarkColorScheme.primary,
145+ unselectedItemColor: kDarkColorScheme.secondary,
146+ ),
136147 ),
148+ themeMode: themeMode,
149+ home: SplashScreen (initDone: initDone, registered: registered),
137150 ),
138- themeMode: themeMode,
139- home: SplashScreen (initDone: initDone, registered: registered),
140151 );
141152 }
142153}
0 commit comments