addListener method

  1. @override
void addListener (ImageListener listener, { ImageErrorListener onError })
override

Adds a listener callback that is called whenever a new concrete ImageInfo object is available or an error is reported. If a concrete image is already available, or if an error has been already reported, this object will call the listener or error listener synchronously.

If the ImageStreamCompleter completes multiple images over its lifetime, this listener will fire multiple times.

The listener will be passed a flag indicating whether a synchronous call occurred. If the listener is added within a render object paint function, then use this flag to avoid calling RenderObject.markNeedsPaint during a paint.

Implementation

@override
void addListener(ImageListener listener, { ImageErrorListener onError }) {
  if (!_hasActiveListeners && _codec != null) {
    _decodeNextFrameAndSchedule();
  }
  super.addListener(listener, onError: onError);
}