load method Null safety

  1. @override
ImageStreamCompleter load(
  1. AssetBundleImageKey key,
  2. DecoderCallback decode

Converts a key into an ImageStreamCompleter, and begins fetching the image.

This method is deprecated. Implement loadBuffer for faster image loading. Only one of load and loadBuffer must be implemented, and loadBuffer is preferred.

The decode callback provides the logic to obtain the codec for the image.

See also:

  • ResizeImage, for modifying the key to account for cache dimensions.


ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) {
  InformationCollector? collector;
  assert(() {
    collector = () => <DiagnosticsNode>[
      DiagnosticsProperty<ImageProvider>('Image provider', this),
      DiagnosticsProperty<AssetBundleImageKey>('Image key', key),
    return true;
  return MultiFrameImageStreamCompleter(
    codec: _loadAsync(key, null, decode),
    scale: key.scale,
    debugLabel: key.name,
    informationCollector: collector,