Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter CachedNetworkImage doesn't work, loading images again when scrolling up to bottom or bottom to up

I'm trying to work with cached images. I followed CachedNetworkImage but it doesn't work. Please help me if any other solution available in flutter

Here is video of my issue

When I scrolled list from up to bottom or bottom to up the images are gone and reloaded again

Code

        ClipRRect(
                  borderRadius: new BorderRadius.only(
                  topRight: Radius.circular(10.0),
                  topLeft: Radius.circular(10.0)),
                  child: CachedNetworkImage(
                       placeholder: (context, url) => Center(
                           child: CircularProgressIndicator(),),
                            imageUrl: productList[position]["images"]
                            ["post_image1"],
                            height: 180,
                            width: MediaQuery.of(context).size.width,
                            fit: BoxFit.cover,
                    ))
like image 232
Gursewak Singh Avatar asked Nov 21 '25 11:11

Gursewak Singh


1 Answers

CachedNetworkImage works fine for me.

Run your app on a simulator / emulator then you can see if the images have been cached. Note that the image size makes a big difference (you don’t want them more than 100K and hopefully < 50K) as even if they are cached, each time they have to be re shown in the UI they have to be decoded. Looking at your video it looks like it takes a long time for the to load initially (which is either a slow internet or large files), then once they are loaded, then you still get the decode time (but that is a lot shorter than the initial download time).

In summary, make sure the images are of a sensible size for use in a mobile app.

like image 145
Agreensh Avatar answered Nov 23 '25 07:11

Agreensh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!