This repository was archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.dart
58 lines (56 loc) · 2.25 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
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hive/hive.dart';
import 'about/blocs/about_bloc.dart';
import 'about/repository/about_repository.dart';
import 'app/app.dart';
import 'app/theme/services/system_ui.dart';
import 'core/models/color_palette/color_palette.dart';
import 'core/services/data_storage.dart';
import 'favorites/blocs/list_favorites/favorites_bloc.dart';
import 'favorites/repository/favorites_repository.dart';
import 'favorites/services/storage_providers/favorites_hive_storage.dart';
import 'onboarding/blocs/onboarding_bloc.dart';
import 'onboarding/repository/onboarding_repository.dart';
import 'onboarding/services/storage_providers/onboarding_hive_storage.dart';
import 'settings/blocs/settings_bloc.dart';
import 'settings/dao/generator_dao.dart';
import 'vibration/blocs/vibration_bloc.dart';
import 'vibration/services/vibrations.dart';
Future<void> main() async {
final HiveCipher? encryption = await const DataStorage().init();
final Vibrations vibrationService = await Vibrations.init();
final GeneratorDAO generatorDao = GeneratorDAO();
const SystemUI().init();
runApp(
MultiBlocProvider(
providers: <BlocProvider<StateStreamableSource<Object?>>>[
BlocProvider<AboutBloc>(lazy: false, create: (_) => AboutBloc(AboutRepository())),
BlocProvider<SettingsBloc>(
lazy: false,
create: (_) => SettingsBloc(generatorDao)..add(const SettingsEvent.started()),
),
BlocProvider<OnboardingBloc>(
lazy: false,
create: (_) => OnboardingBloc(
OnboardingRepository(OnboardingHiveStorage(encryption: encryption)),
)..add(const OnboardingEvent.started()),
),
BlocProvider<FavoritesBloc>(
create: (_) => FavoritesBloc(
FavoritesRepository(
List<ColorPalette>.of(<ColorPalette>[]),
FavoritesHiveStorage(encryption: encryption),
),
)..add(const FavoritesStarted()),
lazy: false,
),
BlocProvider<VibrationBloc>(
create: (_) => VibrationBloc(vibrationService)..add(const VibrationEvent.started()),
lazy: false,
),
],
child: App(generator: generatorDao),
),
);
}