Reputation: 2900
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
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
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