notifyListeners method

  1. @override
void notifyListeners()

Call all the registered listeners.

Call this method whenever the object changes, to notify any clients the object may have changed. Listeners that are added during this iteration will not be visited. Listeners that are removed during this iteration will not be visited after they are removed.

Implementation

@override
void notifyListeners() {
  if (_listeners.isEmpty) return;

  for (final entry in _listeners.entries) {
    final value = entry.value;
    if (runtimeType == value.notifierType) {
      if (value.selector == null) {
        value.listener.call();
      } else {
        value.currentValue = value.selector?.call();
        if (value.currentValue != value.prevValue) {
          value.prevValue = value.currentValue;
          value.listener.call();
        }
      }
    }
  }
}