-
Notifications
You must be signed in to change notification settings - Fork 25
/
my_app.dart
62 lines (58 loc) · 2.07 KB
/
my_app.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
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttour/di/client_module.dart';
import 'package:fluttour/di/config_module.dart';
import 'package:fluttour/di/datasource_module.dart';
import 'package:fluttour/di/repository_module.dart';
import 'package:fluttour/di/usecase_module.dart';
import 'package:fluttour/presentation/home/home_bloc.dart';
import 'package:fluttour/presentation/sliver/sliver_bloc.dart';
import 'package:fluttour/router/gen_route.dart';
import 'package:fluttour/router/navigation_controller.dart';
import 'package:fluttour/util/app_global.dart' as global;
import 'package:fluttour/util/app_observer.dart';
import 'package:fluttour/util/assets/app_locale.dart';
Future<void> myMain() async {
WidgetsFlutterBinding.ensureInitialized();
Bloc.observer = const AppObserver();
await EasyLocalization.ensureInitialized();
runApp(EasyLocalization(
supportedLocales: const [AppLocales.en, AppLocales.zh],
path: AppLocales.path,
fallbackLocale: AppLocales.en,
child: const MyApp(),
));
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => MyAppState();
}
class MyAppState extends State<MyApp>
with
ConfigModule,
ClientModule,
DatasourceModule,
RepositoryModule,
UseCaseModule {
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(create: (_) => HomeBloc(useCase: homeUseCase)),
BlocProvider(create: (_) => SliverBloc(useCase: sliverUseCase))
],
child: MaterialApp(
debugShowCheckedModeBanner: false,
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
navigatorObservers: [global.navigationObserver],
theme: global.theme,
onGenerateRoute: generateRoute,
navigatorKey: NavigationController.globalNavigatorKey,
),
);
}
}