load method Null safety
- ResizeImageKey key,
- DecoderCallback decode
override
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.
Implementation
@override
ImageStreamCompleter load(ResizeImageKey key, DecoderCallback decode) {
Future<ui.Codec> decodeResize(Uint8List buffer, {int? cacheWidth, int? cacheHeight, bool? allowUpscaling}) {
assert(
cacheWidth == null && cacheHeight == null && allowUpscaling == null,
'ResizeImage cannot be composed with another ImageProvider that applies '
'cacheWidth, cacheHeight, or allowUpscaling.',
);
return decode(buffer, cacheWidth: width, cacheHeight: height, allowUpscaling: this.allowUpscaling);
}
final ImageStreamCompleter completer = imageProvider.load(key._providerCacheKey, decodeResize);
if (!kReleaseMode) {
completer.debugLabel = '${completer.debugLabel} - Resized(${key._width}×${key._height})';
}
return completer;
}