restoreObjects static method
Deserializes the previously serialized string into an object and
- updates WrenchStore
- updates Persistence store
Implementation
static Future<void> restoreObjects(
String key,
void Function(
void Function<T>(T t) update,
String modelName,
String jsonStr,
) callback,
) async {
LazyBox lazyBox = Hive.lazyBox(cacheName);
if (lazyBox.isOpen) {
Map<String, String> cacheData =
(await lazyBox.get(key))?.cast<String, String>() ?? {};
for (String modelKey in cacheData.keys) {
WrenchStore.persistObject(modelKey, cacheData[modelKey]!);
callback(WrenchStore.update, modelKey, cacheData[modelKey]!);
}
}
}