notifyStatusListeners method Null safety

void notifyStatusListeners (
  1. AnimationStatus status
)

Calls all the status listeners.

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

Implementation

void notifyStatusListeners(AnimationStatus status) {
  final List<AnimationStatusListener> localListeners = List<AnimationStatusListener>.from(_statusListeners);
  for (final AnimationStatusListener listener in localListeners) {
    try {
      if (_statusListeners.contains(listener))
        listener(status);
    } catch (exception, stack) {
      InformationCollector? collector;
      assert(() {
        collector = () sync* {
          yield DiagnosticsProperty<AnimationLocalStatusListenersMixin>(
            'The $runtimeType notifying status listeners was',
            this,
            style: DiagnosticsTreeStyle.errorProperty,
          );
        };
        return true;
      }());
      FlutterError.reportError(FlutterErrorDetails(
        exception: exception,
        stack: stack,
        library: 'animation library',
        context: ErrorDescription('while notifying status listeners for $runtimeType'),
        informationCollector: collector
      ));
    }
  }
}