defaultValue<T> method

Future Function(bool inBackpack)? defaultValue<T>(
  1. dynamic value
)

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);
    }
  };
}