Baseflow / flutter_cached_network_image

Download, cache and show images in a flutter app
https://baseflow.com
2.45k stars 656 forks source link

Add the ability to set `debugLabel` #973

Open kardenwork opened 2 months ago

kardenwork commented 2 months ago

🏗 Enhancement Proposal

Add the ability to set debugLabel for ImageInfo's produced by MultiImageStreamCompleter.

Pitch

In Flutter, you can set debugInvertOversizedImages which, if set to true, triggers a throw of a FlutterException which has a following text:

Image $debugImageLabel has a display size of $outputWidthĂ—$outputHeight but a decode size of ${image.width}Ă—${image.height}, which uses an additional ${overheadInKilobytes}KB (assuming a device pixel ratio of $maxDevicePixelRatio).

As you can see, it uses debugImageLabel as image indicator for debug. This debugImageLabel is a debugLabel from ImageInfo class. But when MultiImageStreamCompleter from this library emits new ImageInfo object, it completely ignores debugLabel argument, which always results in it being equal to null, which, in case of multiple simultaneously resizing images, makes it impossible to detect the problematic image.

In order to implement this, MultiImageStreamCompleter must receive debugLabel (or debugLabelCallback with some info passed to it) from above (the origin being CachedNetworkImage and CachedNetworkImageProvider) and pass it to all _emitFrame calls inside of it.

Platforms affected (mark all that apply)