ImageLoadingBuilder typedef
Signature used by Image.loadingBuilder to build a representation of the image's loading progress.
This is useful for images that are incrementally loaded (e.g. over a local file system or a network), and the application wishes to give the user an indication of when the image will be displayed.
The child
argument contains the default image widget and is guaranteed to
be non-null. 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.loadingBuilder was null.
The loadingProgress
argument contains the current progress towards loading
the image. This argument will be non-null while the image is loading, but it
will be null in the following cases:
- When the widget is first rendered before any bytes have been loaded.
- When an image has been fully loaded and is available to be painted.
If callers are implementing custom ImageProvider and ImageStream
instances (which is very rare), it's possible to produce image streams that
continue to fire image chunk events after an image frame has been loaded.
In such cases, the child
parameter will represent the current
fully-loaded image frame.
This builder must not return null.
See also:
- Image.loadingBuilder, which makes use of this signature in the Image widget.
- ImageChunkListener, a lower-level signature for listening to raw ImageChunkEvents.
Implementation
typedef ImageLoadingBuilder = Widget Function(
BuildContext context,
Widget child,
ImageChunkEvent? loadingProgress,
);