write<P> method Null safety

void write<P>(
  1. String restorationId,
  2. P value
)

Stores the provided value of type P under the provided restorationId in the bucket.

Any value that has previously been stored under that ID is overwritten with the new value. The provided value must be serializable with the StandardMessageCodec.

Null values will be stored in the bucket as-is. To remove a value, use remove.

See also:

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

Implementation

void write<P>(String restorationId, P value) {
  assert(_debugAssertNotDisposed());
  assert(restorationId != null);
  assert(debugIsSerializableForRestoration(value));
  if (_rawValues[restorationId] != value || !_rawValues.containsKey(restorationId)) {
    _rawValues[restorationId] = value;
    _markNeedsSerialization();
  }
}