I am trying to lazy load Images in any kind of ListView
, GridView
, StaggeredGridView
, SliverGrid
, SliverList
, ScrollablePositionedList
builders.
I am fetching images from network using Image.network
.
I am also using ResizeImage
to reduce the memory taken according to devices screen sizes.
The images are put in cache (which is actually not desired) and never cleared from memory when calling dispose
.
Image.memory
is actually behaving the same way, keeping references to object and not deleting them when calling dispose
.
Here is my related github issue.
How can i only keep in memory the visible items in the ListView
?
You can use :
PaintingBinding.instance!.imageCache!.maximumSizeBytes = 1024 * 1024 * 50; // 50MB
Which cap the size retained in memory.