Re: Proper way to use ListView with lots of Images?

612 views
Skip to first unread message

Eric Seidel

unread,
Jun 4, 2018, 3:57:58 PM6/4/18
to Mike Maksymowych, jonahw...@google.com, Flutter Dev
The root issue is that the default ImageCache holds onto the last 1000 decoded images (regardless of size or memory pressure).  +Jonah Williams is working on fixing this as we speak. :/


On Mon, Jun 4, 2018 at 11:50 AM Mike Maksymowych <mike.mak...@gmail.com> wrote:
Hi,

For example, when building a ListView that functions as a simple Gallery app (i.e. loads photos from the user's external storage), my app quickly runs out of memory and is killed by the system (Android, in this case) when scrolling through the list. This may be exaggerated by Flutter's image decoding (JPEG) always loading the full-size bitmap into cache? Anyway...

What's the proper way to accomplish this with an arbitrarily large number of Images? I'm currently using ListView.builder to create the Widgets containing the Images. It seems that I'll need to manually load and recycle the Images as necessary as the user scrolls; how do we get (e.g. ScrollController) the scroll position and react to it (e.g. on a fling gesture)? Are there any examples for this?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Maksymowych

unread,
Jun 4, 2018, 4:36:39 PM6/4/18
to Flutter Dev
Thank you!
Reply all
Reply to author
Forward
0 new messages