remove<P> method Null safety

P? remove<P>(
  1. String restorationId
)

Deletes the value currently stored under the provided restorationId from the bucket.

The value removed from the bucket is casted to P and returned. If no value was stored under that id, null is returned.

See also:

  • read, which retrieves a stored value from the bucket.
  • write, which stores a value in the bucket.
  • contains, which checks whether any value is stored under a given restoration ID.

Implementation

P? remove<P>(String restorationId) {
  assert(_debugAssertNotDisposed());
  assert(restorationId != null);
  final bool needsUpdate = _rawValues.containsKey(restorationId);
  final P? result = _rawValues.remove(restorationId) as P?;
  if (_rawValues.isEmpty) {
    _rawData.remove(_valuesMapKey);
  }
  if (needsUpdate) {
    _markNeedsSerialization();
  }
  return result;
}