store static method
Saves an object
to local storage.
Implementation
static Future store(String key, object, {bool inBackpack = false}) async {
if (inBackpack == true) {
Backpack.instance.set(key, object);
}
if (!(object is Model)) {
return await manager().write(key: key, value: object.toString());
}
try {
Map<String, dynamic> json = object.toJson();
return await manager().write(key: key, value: jsonEncode(json));
} on NoSuchMethodError catch (_) {
NyLogger.error(
'[NyStorage.store] ${object.runtimeType.toString()} model needs to implement the toJson() method.');
}
}