removeValue method

dynamic removeValue(
  1. String key, {
  2. String? originator,
})

Removes the key from the registry.

If, and only if, the key was registered on the registry will this fire an event on the valueStream with the key so listeners can be notified that the value has changed.

This accepts an optional originator to allow widgets that remove values to know when the stream fires if they are responding to their own event or not.

Implementation

dynamic removeValue(
  String key, {
  String? originator,
}) {
  assert(key.isNotEmpty == true);

  final hasKey = _values.containsKey(key);
  final result = _values.remove(key);
  if (hasKey == true) {
    _valueStreamController?.add(WidgetValueChanged(
      id: key,
      originator: originator,
      value: null,
    ));
  }

  return result;
}