add method
T
add(
- T updatedValue
Implementation
T add(T updatedValue) {
assert(!isClosed, 'Cannot add value to a closed computable.');
_value = updatedValue;
_updateIndex = _nextUpdateIndex++;
// Check whether the event should be added to the controller.
if (isClosed || (!_isFirstEvent && _value == _controllerValue && dedupe)) {
return _value;
}
_controllerValue = _value;
_isFirstEvent = false;
if (!_eventScheduled) {
_eventScheduled = true;
Future.delayed(
Duration.zero,
() {
if (hasListener) {
_controller!.add(_value);
}
_eventScheduled = false;
},
);
}
// Notify all dependents that the computable's value has changed.
for (final dependent in _dependents) {
dependent._onDependencyChange(this);
}
return _value;
}