saveAndUpdate method

Future<E?> saveAndUpdate(
  1. E? handle(
    1. E? oldValue
    ), [
  2. String key = 'default',
  3. E? defaultValue
])

Implementation

Future<E?> saveAndUpdate(E? Function(E? oldValue) handle, [String key = 'default', E? defaultValue]) async {
  final oldV = await getValue(key, defaultValue: defaultValue);
  final newV = handle.call(oldV);
  if (newV != null) {
    await setValue(key, newV);
  }
  return newV;
}