-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
67 lines (59 loc) · 1.92 KB
/
main.dart
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
import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
import "package:provider/provider.dart";
import "interfaces/libs/l10n.dart";
import "interfaces/libs/providers.dart";
import "interfaces/libs/themes.dart";
import "interfaces/modules.dart";
import "libs/constants.dart";
import "libs/extensions.dart";
import "service_locator.dart";
void main() async {
WidgetsFlutterBinding.ensureInitialized();
LicenseRegistry.addLicense(() async* {
yield LicenseEntryWithLineBreaks(
["google_fonts"],
await rootBundle.rubikFontLicense(),
);
});
await ServiceLocator.init();
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider.value(value: AuthProvider()),
ChangeNotifierProvider.value(value: StoriesProvider()),
],
builder: (context, _) {
/// To make sure redirect did'nt triggered on theme changes.
final appRouter = router(context);
return MultiProvider(
providers: [
ChangeNotifierProvider.value(value: ThemeModeProvider()),
ChangeNotifierProvider.value(value: LocaleProvider()),
],
builder: (context, _) {
return MaterialApp.router(
routerConfig: appRouter,
title: kAppName,
debugShowCheckedModeBanner: false,
//
theme: AppThemes.light,
darkTheme: AppThemes.dark,
themeMode: context.watch<ThemeModeProvider>().value,
//
localizationsDelegates: AppL10n.localizationsDelegates,
supportedLocales: AppL10n.supportedLocales,
locale: context.watch<LocaleProvider>().value,
);
},
);
},
);
}
}