notifyListeners method

  1. @protected
void notifyListeners ()
@protected

Should be called only by Model when the model has changed.

Implementation

@protected
void notifyListeners() {
  // We schedule a microtask to debounce multiple changes that can occur
  // all at once.
  if (_microtaskVersion == _version) {
    _microtaskVersion++;
    scheduleMicrotask(() {
      _version++;
      _microtaskVersion = _version;

      // Convert the Set to a List before executing each listener. This
      // prevents errors that can arise if a listener removes itself during
      // invocation!
      _listeners.toList().forEach((VoidCallback listener) => listener());
    });
  }
}