ImageFrameBuilder typedef

ImageFrameBuilder = Widget Function(BuildContext context, Widget child, int? frame, bool wasSynchronouslyLoaded)

Signature used by Image.frameBuilder to control the widget that will be used when an Image is built.

The child argument contains the default image widget. Typically, this builder will wrap the child widget in some way and return the wrapped widget. If this builder returns child directly, it will yield the same result as if Image.frameBuilder was null.

The frame argument specifies the index of the current image frame being rendered. It will be null before the first image frame is ready, and zero for the first image frame. For single-frame images, it will never be greater than zero. For multi-frame images (such as animated GIFs), it will increase by one every time a new image frame is shown (including when the image animates in a loop).

The wasSynchronouslyLoaded argument specifies whether the image was available synchronously (on the same rendering pipeline frame as the Image widget itself was created) and thus able to be painted immediately. If this is false, then there was one or more rendering pipeline frames where the image wasn't yet available to be painted. For multi-frame images (such as animated GIFs), the value of this argument will be the same for all image frames. In other words, if the first image frame was available immediately, then this argument will be true for all image frames.

See also:

Implementation

typedef ImageFrameBuilder = Widget Function(
  BuildContext context,
  Widget child,
  int? frame,
  bool wasSynchronouslyLoaded,
);