update method

  1. @override
void update(
  1. ValueCell cell,
  2. bool didChange
)
override

The observed cell has changed its value.

This method is called after the value of cell has been recomputed.

If it is known that the value of cell has not changed, didChange is false otherwise a value of true for didChange indicates that cell's value may have changed (but necessarily has).

cell.value now holds the cell's new value.

Implementation

@override
void update(ValueCell cell, bool didChange) {
  if (updating) {
    assert(_changedDependencies > 0, 'CellObserver.update called more times than CellObserver.willUpdate.\n\n'
        'The number of calls to CellObserver.update must match exactly the '
        'number of calls to CellObserver.willUpdate\n\n'
        'This indicates a bug in Live Cells unless the error originates from a'
        'ValueCell subclass provided by a third party, in which case it indicates'
        "a bug in the third party's code."
    );

    _didChange = _didChange || didChange;

    if (--_changedDependencies == 0) {
      stale = stale || _didChange;
      onUpdate(_didChange && this.didChange());

      updating = false;

      if (_didChange) {
        postUpdate();
      }
    }
  }
}