Skip to content

Commit 644f454

Browse files
committed
conf: Add support for multiple build flavors.
1 parent 09461be commit 644f454

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

lib/main_development.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'dart:async';
2+
3+
import 'package:flutter/foundation.dart';
4+
import 'package:flutter/material.dart';
5+
import 'package:hive_flutter/hive_flutter.dart';
6+
import 'package:hydrated_bloc/hydrated_bloc.dart';
7+
import 'package:path_provider/path_provider.dart';
8+
9+
import 'data/constants/strings.dart';
10+
import 'presentation/core/main_app.dart';
11+
12+
Future<void> main() async {
13+
// Necessary if you intend to initialize in an async function.
14+
WidgetsFlutterBinding.ensureInitialized();
15+
16+
await _initHive();
17+
final hydratedStorage = await _initHydratedBloc();
18+
19+
// Zone for Hydrated Bloc.
20+
HydratedBlocOverrides.runZoned(
21+
() async => runApp(await Codephile.run()),
22+
storage: hydratedStorage,
23+
);
24+
}
25+
26+
Future<void> _initHive() async {
27+
await Hive.initFlutter();
28+
await Hive.openBox(AppStrings.hiveBoxName);
29+
}
30+
31+
Future<Storage> _initHydratedBloc() async {
32+
return HydratedStorage.build(
33+
storageDirectory: kIsWeb
34+
? HydratedStorage.webStorageDirectory
35+
: await getApplicationSupportDirectory(),
36+
);
37+
}
File renamed without changes.

0 commit comments

Comments
 (0)