initHiveKvStorage function
Creates a KvStorage backed by a Hive Box, opening the box by name.
This factory avoids exposing Hive Box to consumer code and initializes
Hive automatically on first use.
Implementation
Future<KvStorage> initHiveKvStorage({
String boxName = '@ifl',
HiveInterface? hive,
String subDir = 'kv_storage',
}) async {
final hiveClient = hive ?? Hive;
if (identical(hiveClient, Hive)) {
await _ensureDefaultHiveInitialized(subDir);
}
final box = await hiveClient.openBox<String>(boxName);
return HiveKvStorage(HiveBoxAdapter(box));
}