|
1 |
| -import 'package:flutter/material.dart'; |
2 |
| -import 'package:flutter/services.dart'; |
3 |
| -import 'package:flutter_bloc/flutter_bloc.dart'; |
4 |
| -import 'package:flutter_localized_locales/flutter_localized_locales.dart'; |
5 |
| -import 'package:flutter_native_splash/flutter_native_splash.dart'; |
6 |
| -import 'package:gpt_detector/app/l10n/cubit/l10n_cubit.dart'; |
7 |
| -import 'package:gpt_detector/app/l10n/extensions/app_l10n_extensions.dart'; |
8 |
| -import 'package:gpt_detector/app/theme/cubit/theme_cubit.dart'; |
9 |
| -import 'package:gpt_detector/app/theme/dark/dark_theme.dart'; |
10 |
| -import 'package:gpt_detector/app/theme/light/light_theme.dart'; |
11 |
| -import 'package:gpt_detector/core/extensions/context_extensions.dart'; |
12 |
| -import 'package:gpt_detector/core/utils/observer/bloc_observer.dart'; |
13 |
| -import 'package:gpt_detector/feature/splash/presentation/view/splash_view.dart'; |
14 |
| -import 'package:gpt_detector/locator.dart'; |
15 |
| -import 'package:hydrated_bloc/hydrated_bloc.dart'; |
16 |
| -import 'package:path_provider/path_provider.dart'; |
| 1 | +import 'package:gpt_detector/app/view/app.dart'; |
| 2 | +import 'package:gpt_detector/bootstrap.dart'; |
17 | 3 |
|
18 | 4 | Future<void> main() async {
|
19 |
| - final widgetBinding = WidgetsFlutterBinding.ensureInitialized(); |
20 |
| - // Initialize Flutter Native Splash |
21 |
| - FlutterNativeSplash.preserve(widgetsBinding: widgetBinding); |
22 |
| - // Initialize Hydrated Bloc |
23 |
| - HydratedBloc.storage = await HydratedStorage.build( |
24 |
| - storageDirectory: await getApplicationDocumentsDirectory(), |
25 |
| - ); |
26 |
| - // Initialize Bloc Observer |
27 |
| - Bloc.observer = AppBlocObserver(); |
28 |
| - // Initialize Locator |
29 |
| - await Locator.locateServices(); |
30 |
| - // Set Screen Orientation |
31 |
| - await SystemChrome.setPreferredOrientations( |
32 |
| - [DeviceOrientation.portraitUp], |
33 |
| - ); |
34 |
| - runApp(const GPTDetector()); |
35 |
| -} |
36 |
| - |
37 |
| -class GPTDetector extends StatelessWidget { |
38 |
| - const GPTDetector({super.key}); |
39 |
| - |
40 |
| - @override |
41 |
| - Widget build(BuildContext context) { |
42 |
| - return MultiBlocProvider( |
43 |
| - providers: [ |
44 |
| - BlocProvider( |
45 |
| - create: (context) => Locator.instance<L10nCubit>(), |
46 |
| - ), |
47 |
| - BlocProvider( |
48 |
| - create: (context) => Locator.instance<ThemeCubit>(), |
49 |
| - ), |
50 |
| - ], |
51 |
| - child: BlocBuilder<ThemeCubit, ThemeState>( |
52 |
| - builder: (context, themeState) { |
53 |
| - return BlocBuilder<L10nCubit, L10nState>( |
54 |
| - builder: (context, l10nState) { |
55 |
| - return MaterialApp( |
56 |
| - debugShowCheckedModeBanner: false, |
57 |
| - |
58 |
| - builder: (context, child) => MediaQuery( |
59 |
| - // Disables font scaling and bold text |
60 |
| - data: context.mediaQuery.copyWith(textScaler: TextScaler.noScaling, boldText: false), |
61 |
| - // Dismisses the keyboard globally |
62 |
| - child: GestureDetector( |
63 |
| - onTap: () => FocusManager.instance.primaryFocus?.unfocus(), |
64 |
| - child: child, |
65 |
| - ), |
66 |
| - ), |
67 |
| - |
68 |
| - // Theme |
69 |
| - themeMode: themeState.themeMode, |
70 |
| - theme: Locator.instance<LightTheme>().theme, |
71 |
| - darkTheme: Locator.instance<DarkTheme>().theme, |
72 |
| - |
73 |
| - // Localization |
74 |
| - locale: l10nState.locale, |
75 |
| - supportedLocales: AppLocalizations.supportedLocales, |
76 |
| - localizationsDelegates: const [ |
77 |
| - ...AppLocalizations.localizationsDelegates, |
78 |
| - LocaleNamesLocalizationsDelegate(), |
79 |
| - ], |
80 |
| - |
81 |
| - home: const SplashView(), |
82 |
| - ); |
83 |
| - }, |
84 |
| - ); |
85 |
| - }, |
86 |
| - ), |
87 |
| - ); |
88 |
| - } |
| 5 | + await bootstrap(builder: App.new); |
89 | 6 | }
|
0 commit comments