Flutter app crashes a lot when cached_network_image Or Image.Network is populated with data , just showing lost connection to device nothing more Flutter app crashes a lot when cached_network_image Or Image.Network is populated with data , just showing lost connection to device nothing more dart dart

Flutter app crashes a lot when cached_network_image Or Image.Network is populated with data , just showing lost connection to device nothing more


For long image lists or grids, I used Image.network with a reasonable cacheHeight and cacheWidth parameter (around 200 +/-). That fixed the memory increase problem for me. Otherwise I have not found a solution to this using cachedimage. Even the simplest cachednetworkimage sample code from the tutorial doesn't work if we provide it with a list of even 10 odd elements if the images are large (large a.k.a. jpgs with 2 odd Mb each). Immediately memory goes to 3-4-500Mb and then we get out of memory error.

But another issue is, Image.network does not have good error handling.


The images could just be a manifestation of an underlying issue. You stated that you have over 20 routes. How are you managing your state when you fetch data. Apart from the images, it seems like your still using the network to fetch other data which may result in high resource usage.6 images of 200-400KB is considerably small. Since you had the issue with both image.asset and the CacheNetworkImage widgets, I suspect the issue is you are not caching the data you had fetched. Possibly, every time you scroll back up, you find blank spaces which results in fetching the resources again. The Listview.builder builds on demand.


You can use cached_network_image. Set

memCacheHeight and memCacheWidth

attributes of CachedNetworkImage.This worked for loading the large number of images.