initialize method
Implementation
@override
Future<HiveLocalAdapter<T>> initialize() async {
if (isInitialized) return this;
if (!_hiveLocalStorage.hive.isBoxOpen(_internalType)) {
if (!_hiveLocalStorage.hive.isAdapterRegistered(typeId)) {
_hiveLocalStorage.hive.registerAdapter(this);
}
if (_hiveLocalStorage.clear) {
await _hiveLocalStorage.deleteBox(_internalType);
}
}
try {
box = await _hiveLocalStorage.openBox<T>(_internalType);
} catch (e) {
await _hiveLocalStorage.deleteBox(_internalType);
box = await _hiveLocalStorage.openBox<T>(_internalType);
}
return this;
}