Baseflow / flutter_cached_network_image

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

Using memCacheWidth/height along with imageBuilder has no effect. #769

Open irjayjay opened 1 year ago

irjayjay commented 1 year ago

🐛 Bug Report

When adding a memCacheWidth or memCacheHeight, the cached version of the image doesn't get passed to the imageBuilder, so the image stays its original size.

When using debugInvertOversizedImages = true; the image is clearly still too large for its container. Removing the imageBuilder fixes this error.

Expected behavior

Image rendered through the imageBuilder should be lower resolution or smaller size.

Reproduction steps

Run the following with an image:

CachedNetworkImage(
                  imageUrl: imageUrl.toString(),
                  memCacheWidth: 50,
                  imageBuilder: (context, imageProvider) {
                    return Container(
                      width: double.infinity,
                      height: 150,
                      decoration: BoxDecoration(
                        image: DecorationImage(
                          image: imageProvider,
                          fit: BoxFit.cover,
                        ),
                      ),
                    );
                  },
                ),

Configuration

As above.

Version: 3.2.0

Platform:

lihehehehe commented 1 year ago

🐛 Bug Report

When adding a memCacheWidth or memCacheHeight, the cached version of the image doesn't get passed to the imageBuilder, so the image stays its original size.

When using debugInvertOversizedImages = true; the image is clearly still too large for its container. Removing the imageBuilder fixes this error.

Expected behavior

Image rendered through the imageBuilder should be lower resolution or smaller size.

Reproduction steps

Run the following with an image:

CachedNetworkImage(
                  imageUrl: imageUrl.toString(),
                  memCacheWidth: 50,
                  imageBuilder: (context, imageProvider) {
                    return Container(
                      width: double.infinity,
                      height: 150,
                      decoration: BoxDecoration(
                        image: DecorationImage(
                          image: imageProvider,
                          fit: BoxFit.cover,
                        ),
                      ),
                    );
                  },
                ),

Configuration

As above.

Version: 3.2.0

Platform:

  • [ ] 📱 iOS
  • [x] 🤖 Android

Hi bro ! You can try update version to cached_network_image: ^3.2.2

lubritto commented 1 year ago

Yes, it's because the image provider we are receiving is not applying the ResizeImage. I believe the implementation of imageBuilder on this package needs to be refactored, to make sure that we will receive the image based on the CachedNetworkImage settings