save method
Save the object to secure storage using a unique key
.
E.g. User class
User user = new User(); user.name = "Anthony"; user.save('com.company.app.auth_user');
Get user User user = await NyStorage.read
Implementation
Future save({bool inBackpack = false}) async {
if (_key == null) {
NyLogger.error(
'static StorageKey key = "${runtimeType.toString()}" is not defined for ${runtimeType.toString()}. Please define a key for this model.'
'${runtimeType.toString()}() : super(key: key);'
'');
return;
}
await NyStorage.save(_key!, this);
if (inBackpack == true) {
Backpack.instance.save(_key!, this);
}
}