Application crashes when using CachedNetworkImage in listview. If there are a lot of pictures, then the application freezes and crashes. Is it possible to load each image one by one, asynchronously? Can I have a code example? Thanks.
And so, if you have the same problem as me, and you have a large list of pictures, then you can do the following:
1.Enable ListView pagination. So that when scrolling, not the entire ListView is loaded, but for example only 10 items from the List.
2.Compress pictures to the desired size using the following parameters:
memCacheWidth, memCacheHeight, maxHeightDiskCache, maxWidthDiskCache
Here is my example:
CachedNetworkImage(
memCacheWidth: 45,
memCacheHeight: 60,
maxHeightDiskCache: 60,
maxWidthDiskCache: 45,
imageUrl: imageUrl,
imageBuilder: (context, imageProvider) => imageBuilderWidget(imageProvider),
placeholder: (context, url) => placeholderWidget(),
errorWidget: (context, url, error) => errorWidget(),
);
After adding these options, remove app from the emulator and do a flutter clean
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