editValue<T> static method

Future<void> editValue<T>(
  1. String key,
  2. T update(
    1. T
    )
)

Implementation

static Future<void> editValue<T>(String key, T Function(T) update) async {
  final currentValue = getValue<T>(key);
  final newValue = update(currentValue);
  if (newValue != null) {
    await setValue<T>(key, newValue);
  } else {
    await deleteValue(key);
  }
}