-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.dart
74 lines (61 loc) · 1.96 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
72
73
74
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:get_it/get_it.dart';
import 'package:log_keep/bloc/loggable_bloc_observer.dart';
import 'package:log_keep/repositories/auth_repository.dart';
import 'package:log_keep/repositories/logs_repository.dart';
import 'package:log_keep/repositories/mock/mock_auth_repository.dart';
import 'package:log_keep/repositories/mock/mock_logs_repository.dart';
import 'package:logger/logger.dart';
GetIt getIt = GetIt.instance;
FirebaseApp firebaseApp;
Logger logger;
class App {
static Future initializeApp() async {
WidgetsFlutterBinding.ensureInitialized();
initializeLogging();
if (!kReleaseMode) {
Bloc.observer = LoggableBlocObserver();
}
getIt.registerSingleton<AuthRepository>(
MockAuthRepository(),
signalsReady: true);
getIt.registerSingleton<LogsRepository>(
MockLogsRepository(),
signalsReady: true);
// TODO uncomment this when your Firebase account is ready
/*
firebaseApp = await Firebase.initializeApp();
getIt.registerSingleton<AuthRepository>(
FirebaseAuthRepository(),
signalsReady: true);
getIt.registerSingleton<LogsRepository>(
FirestoreLogsRepository(FirebaseFirestore.instance),
signalsReady: true);
*/
getIt<AuthRepository>().initialize();
getIt<LogsRepository>().initialize();
}
static void initializeLogging() {
logger = Logger(
filter: CommonLogFilter(),
printer: PrettyPrinter(
methodCount: 2,
errorMethodCount: 8,
lineLength: 120,
colors: true,
printEmojis: true,
printTime: false
),
);
}
}
class CommonLogFilter extends LogFilter {
@override
bool shouldLog(LogEvent event) {
return !kReleaseMode;
}
}