What does 'Long lists' mean in flutter's list view builder

Viewed 946

In the article https://flutter.dev/docs/cookbook/lists/long-lists, they say you could use a list view builder when dealing with long lists. But what does 'Long Lists' mean? Is it hundreds, thousands or tens of thousands of entries? Or does it just mean a dynamic list?

In my code, i've been making decisions on how to build the app based on trying to use list view builder (e.g. i haven't been nesting lists within other scroll views as that appears to remove the builder functionality), but this makes my code more complicated.

I ran an app in --profile mode with 10000 ListTile widgets and found them both to be very performant during scrolling and initial load. I couldn't really see a difference from the performance overlay. So I don't really know what to conclude about ListView.builder.

Edit: Should note that I tested on a cheap Samsung Galaxy A10

1 Answers

Both ListView and ListView.Builder extends ScrollView internally which Creates a scrollable, linear array of widgets from an explicit [List].

This ListView is appropriate for list views with a large (or infinite) number of children because the builder is called only for those children that are actually visible.

ListView calculates maximum scroll extent for all items in the list, that is actually taking time, but performance-wise not such an impact where user can see by their eyes.

The ListView.Builder should actually create the widget instances when called. Avoid using a builder that returns a previously-constructed widget. So it's only calculating scroll intent for visible items which in case of Listview missing.

So there is no specific count that should be considered in-between, but if we have 100 items with the large widget tree, it will have some impact on memory usage of scrolling. For it, memory profiling should be used.

Related