notifyListeners method

  1. @protected
void notifyListeners()

Calls all the listeners.

If listeners are added or removed during this function, the modifications will not change which listeners are called during this iteration.

Implementation

@protected
@pragma('vm:notify-debugger-on-exception')
void notifyListeners() {
  final List<VoidCallback> localListeners = _listeners.toList(growable: false);
  for (final VoidCallback listener in localListeners) {
    InformationCollector? collector;
    assert(() {
      collector = () => <DiagnosticsNode>[
        DiagnosticsProperty<AnimationLocalListenersMixin>(
          'The $runtimeType notifying listeners was',
          this,
          style: DiagnosticsTreeStyle.errorProperty,
        ),
      ];
      return true;
    }());
    try {
      if (_listeners.contains(listener)) {
        listener();
      }
    } catch (exception, stack) {
      FlutterError.reportError(FlutterErrorDetails(
        exception: exception,
        stack: stack,
        library: 'animation library',
        context: ErrorDescription('while notifying listeners for $runtimeType'),
        informationCollector: collector,
      ));
    }
  }
}