mohammad
mohammad

Reputation: 2900

how to cache image which don't affect UI and GPU performane

I want to cache an image with CachedNetworkImage. But because my network image has high quality, I face the issue that my list and grids are not rendered smoothly. So I test image.network to reduce image quality but unfortunately it has not faded in image animation.

So I want to reduce quality with fade in the image. I am new to flutter and want to know which way is optimal to handle this field.

              CachedNetworkImage(
                  fadeInDuration = const Duration(milliseconds: 400),
                  fit: BoxFit.cover,
                  imageUrl: i,
                  width: 1000,
                ),

              Image.network(
                      i,
                      fit: BoxFit.cover,
                      filterQuality: FilterQuality.low,
                      width: 1000,
                    )

I want to cache my images while the user is in app and if the app is exited, clear the cached image.

Upvotes: 2

Views: 2472

Answers (2)

Son of Stackoverflow
Son of Stackoverflow

Reputation: 1679

Solution code:

     CachedNetworkImage(
        fadeInDuration : const Duration(milliseconds: 400),
        fit: BoxFit.cover,
        imageUrl: i,
        width: 1000,
        placeholder: (context, url) => new Image.asset('assets/images/placeholder.jpg'), // Your default image here

     ),

Upvotes: 2

Akora Ing. DKB
Akora Ing. DKB

Reputation: 1051

I don't know if this will be the best solution for your case but try the cached_network_image package.

Upvotes: 0

Related Questions