Flutter recommends to use cached_network_image
here https://flutter.dev/docs/cookbook/images/cached-images. I used it and it worked fine. I tried NetworkImage
and it worked, too.
I read from the doc that NetworkImage
also caches the downloaded image locally. So what's the point in using cached_network_image
instead of NetworkImage
? Is there a comparison how their caching strategies differentiate from one another? Thanks!
The difference is significant and really helpful too...as you know fetching image from network takes time so cached network image provides you options for space holder to show when loading and error widget when can't load which are not there in NetworkImage. As a developer, you must be ready for every situation so that's the reason for recommending cached network images.
UPDATE: ImageNetwork now has a loadingBuilder and errorbuilder parameters, so it too can now show a loading indicator similar to cached network image. But in CachedImageNetwork once the image is loaded it's cached in the system until the URL changes, which gives faster loading of the image every time and there are also many more features to explore please see official read me documents.
So still I prefer cachedNetworkImage until NetworkImage has similar features.
Hope you understand! Otherwise, let me know in the comments down below!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With