loadLocalOrNetworkImageCodec function

Stream<Codec> loadLocalOrNetworkImageCodec({
  1. required LoadImageOption option,
  2. required dynamic decode,
  3. StreamController<ImageChunkEvent>? chunkEvents,
  4. void evictImageAsync()?,
})

Loads local image codec or cached network image codec, using given option and chunkEvents, which is used by LocalOrCachedNetworkImageProvider. If the image is downloaded, it will also be recorded to given CacheManager.

Implementation

Stream<ui.Codec> loadLocalOrNetworkImageCodec({
  required LoadImageOption option,
  required DecoderCallback decode,
  StreamController<ImageChunkEvent>? chunkEvents,
  void Function()? evictImageAsync,
}) async* {
  var stream = loadLocalOrNetworkImageBytes(
    option: option,
    chunkEvents: chunkEvents,
    evictImageAsync: evictImageAsync,
  );
  await for (var bytes in stream) {
    yield await decode(bytes);
  }
}