loadBuffer method Null safety

  1. @override
ImageStreamCompleter loadBuffer(
  1. MemoryImage key,
  2. DecoderBufferCallback decode
)
override

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

For backwards-compatibility the default implementation of this method calls through to ImageProvider.load. However, implementors of this interface should only override this method and not ImageProvider.load, which is deprecated.

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.

Implementation

@override
ImageStreamCompleter loadBuffer(MemoryImage key, DecoderBufferCallback decode) {
  return MultiFrameImageStreamCompleter(
    codec: _loadAsync(key, decode, null),
    scale: key.scale,
    debugLabel: 'MemoryImage(${describeIdentity(key.bytes)})',
  );
}