setImage method Null safety

  1. @protected
void setImage(
  1. ImageInfo image
)

Calls all the registered listeners to notify them of a new image.

Implementation

@protected
@pragma('vm:notify-debugger-on-exception')
void setImage(ImageInfo image) {
  _checkDisposed();
  _currentImage?.dispose();
  _currentImage = image;

  if (_listeners.isEmpty) {
    return;
  }
  // Make a copy to allow for concurrent modification.
  final List<ImageStreamListener> localListeners =
      List<ImageStreamListener>.of(_listeners);
  for (final ImageStreamListener listener in localListeners) {
    try {
      listener.onImage(image.clone(), false);
    } catch (exception, stack) {
      reportError(
        context: ErrorDescription('by an image listener'),
        exception: exception,
        stack: stack,
      );
    }
  }
}