MultiFrameImageStreamCompleter class

Manages the decoding and scheduling of image frames.

New frames will only be emitted while there are registered listeners to the stream (registered with addListener).

This class deals with 2 types of frames:

  • image frames - image frames of an animated image.
  • app frames - frames that the flutter engine is drawing to the screen to show the app GUI.

For single frame images the stream will only complete once.

For animated images, this class eagerly decodes the next image frame, and notifies the listeners that a new frame is ready on the first app frame that is scheduled after the image frame duration has passed.

Scheduling new timers only from scheduled app frames, makes sure we pause the animation when the app is not visible (as new app frames will not be scheduled).

See the following timeline example:

| Time | Event                                      | Comment                   |
| t1   | App frame scheduled (image frame A posted) |                           |
| t2   | App frame scheduled                        |                           |
| t3   | App frame scheduled                        |                           |
| t4   | Image frame B decoded                      |                           |
| t5   | App frame scheduled                        | t5 - t1 < frameB_duration |
| t6   | App frame scheduled (image frame B posted) | t6 - t1 > frameB_duration |


MultiFrameImageStreamCompleter({required Future<Codec> codec, required double scale, String? debugLabel, Stream<ImageChunkEvent>? chunkEvents, InformationCollector? informationCollector})
Creates a image stream completer.


debugLabel String?
A string identifying the source of the underlying image.
read / writeinherited
hashCode int
The hash code for this object.
hasListeners bool
Whether any listeners are currently registered.
runtimeType Type
A representation of the runtime type of the object.


addListener(ImageStreamListener listener) → void
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 notify the listener synchronously.
addOnLastListenerRemovedCallback(VoidCallback callback) → void
Adds a callback to call when removeListener results in an empty list of listeners and there are no keepAlive handles outstanding.
debugFillProperties(DiagnosticPropertiesBuilder description) → void
Accumulates a list of strings describing the object's state. Subclasses should override this to have their information included in toString.
keepAlive() ImageStreamCompleterHandle
Creates an ImageStreamCompleterHandle that will prevent this stream from being disposed at least until the handle is disposed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
removeListener(ImageStreamListener listener) → void
Stops the specified listener from receiving image stream events.
removeOnLastListenerRemovedCallback(VoidCallback callback) → void
Removes a callback previously supplied to addOnLastListenerRemovedCallback.
reportError({DiagnosticsNode? context, required Object exception, StackTrace? stack, InformationCollector? informationCollector, bool silent = false}) → void
Calls all the registered error listeners to notify them of an error that occurred while resolving the image.
reportImageChunkEvent(ImageChunkEvent event) → void
Calls all the registered ImageChunkListeners (listeners with an ImageStreamListener.onChunk specified) to notify them of a new ImageChunkEvent.
setImage(ImageInfo image) → void
Calls all the registered listeners to notify them of a new image.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel =}) String
A string representation of this object.
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.


operator ==(Object other) bool
The equality operator.