defaultValue<T> method
Set a default value for a StorageKey
Implementation
Future Function(bool inBackpack)? defaultValue<T>(value) {
return (inBackpack) async {
dynamic localValue = await fromStorage();
if (localValue == null) {
await save(value, inBackpack: inBackpack);
Backpack.instance.save(this, value);
return;
}
if (inBackpack) {
dynamic data = await storageRead<T>(this);
Backpack.instance.save(this, data);
}
};
}