notifyUpdate method

void notifyUpdate({
  1. bool isEqual = false,
  2. bool didChange = true,
})

Notify the observers of the cell that the cell's value has changed.

This should be called after the value of the cell has changed to a new value following a notifyWillChange call.

If isEqual is true then only the observers, for which CellObserver.shouldNotifyAlways is true, are notified.

A value of false for didChange indicates that the cell's values has not changed. A value of true indicates that it may have changed.

Implementation

void notifyUpdate({
  bool isEqual = false,
  bool didChange = true
}) {
  assert(!_isDisposed);
  assert(--_notifyCount >= 0, 'Notify count is less than zero when calling CellState.notifyUpdate.\n\n'
      'This indicates that there have been more calls to CellState.notifyUpdate '
      'than CellState.notifyWillUpdate, in the current update cycle. The number of '
      'calls to notifyUpdate should match exactly the number of calls to notifyWillUpdate.\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."
  );

  final wasUpdating = CellUpdateManager.beginCellUpdates();

  for (final observer in _observers.keys.toList(growable: false)) {
    try {
      if (!isEqual || observer.shouldNotifyAlways) {
        observer.update(cell, !isEqual && didChange);
      }
    }
    catch (e, st) {
      debugPrint('Unhandled exception in CellObserver.update: $e\n$st');
    }
  }

  CellUpdateManager.endCellUpdates(wasUpdating);
}