add method

  1. @override
void add(
  1. T t
)
override

Adds t to this stream.

If this ValueStream is sync, notifies listeners before returning, unless if t compares == to the value last used to notify the listeners. If this ValueStream is not sync, notifies listeners in the next microtask. Further calls to add or addError within a single microtask will override previous calls. In the next microtask, the listeners are notified with the last-added value, unless if it compares == to the value last used to notify them.

If there are no listeners, buffers t and drops any previusly buffered values/errors.

Implementation

@override
void add(T t) {
  _lastAddedValue = _ValueOrException.value(t);
  if (!_sync && _controller.hasListener) {
    if (_controllerAddScheduled) return;
    _controllerAddScheduled = true;
    scheduleMicrotask(_controllerAddMicrotask);
  } else {
    _controllerAddMicrotask();
  }
}