initialize static method
Initializes Hive and opens all registered box collections. Must be called before using any HHive instances.
Implementation
static Future<void> initialize() async {
if (_alreadyInitialized) {
return;
}
_alreadyInitialized = true;
Hive.init(
HIVE_INIT_PATH,
backendPreference: HIVE_STORAGE_BACKEND_PREFERENCE,
);
// open box collections
final List<String> boxes = [];
for (final config in HHImmutableConfig.instances.values) {
boxes.add(config.env);
if (config.usesMeta) {
boxes.add('_meta_${config.env}');
}
}
_hiveBoxCollection = await BoxCollection.open(
_hiveBoxCollectionName,
boxes.toSet(),
path: HIVE_INIT_PATH,
key: HIVE_CIPHER,
);
}