forked from wednesday-solutions/flutter_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.dart
71 lines (59 loc) · 2.17 KB
/
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
63
64
65
66
67
68
69
70
71
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:flutter_template/domain/di/domain_module.dart';
import 'package:flutter_template/foundation/logger/logger.dart';
import 'package:flutter_template/interactor/di/interactor_module.dart';
import 'package:flutter_template/navigation/di/navigation_module.dart';
import 'package:flutter_template/presentation/di/presentation_module.dart';
import 'package:flutter_template/presentation/intl/translations/translation_loader.dart';
import 'package:flutter_template/presentation/template_app.dart';
import 'package:flutter_template/repository/di/repository_module.dart';
import 'package:flutter_template/services/di/service_module.dart';
import 'package:get_it/get_it.dart';
import 'package:shared_preferences/shared_preferences.dart';
void startApp() async {
await _initialiseApp();
runApp(EasyLocalization(
supportedLocales: const [Locale("en", "US"), Locale("hi", "IN")],
path: "assets/translations",
fallbackLocale: const Locale("en", "US"),
assetLoader: const CodegenLoader(),
child: TemplateApp(),
));
}
Future _initialiseApp() async {
final bindings = WidgetsFlutterBinding.ensureInitialized();
bindings.deferFirstFrame();
_initialiseGetIt();
await Future.wait([
_initSharedPreferences(),
EasyLocalization.ensureInitialized(),
]);
EasyLocalization.logger.printer = customEasyLogger;
if (!kIsWeb && Platform.isAndroid) {
try {
FlutterDisplayMode.setHighRefreshRate();
} on PlatformException catch (exception) {
log.e(exception);
}
}
bindings.allowFirstFrame();
}
Future _initSharedPreferences() async {
final sharedPreferences = await SharedPreferences.getInstance();
GetIt.instance.registerSingleton(sharedPreferences);
}
void _initialiseGetIt() {
log.d("Initializing dependencies...");
GetIt.instance
..serviceModule()
..repositoryModule()
..domainModule()
..interactorModule()
..presentationModule()
..navigationModule();
}