save static method
Saves an object
to local storage.
Implementation
static Future save(String key, object, {bool inBackpack = false}) async {
if (inBackpack == true) {
Backpack.instance.save(key, object);
}
if (object is! Model) {
await manager().write(
key: "${key}_runtime_type", value: object.runtimeType.toString());
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.');
}
}