Liew Syet Chau
Liew Syet Chau

Reputation: 163

Will Large list of data in Flutter causing poor performance?

I am developing flutter app and the APIs return 1k-2k list of data and assign the data to ListView. When I switch index of choiceChip, I need to filter the list and rebuild the ListView. My app seem lagging for awhile. Is the size of list will affect the rebuilding of listView when setState() ?

Upvotes: 0

Views: 1197

Answers (1)

Pooja Soni
Pooja Soni

Reputation: 82

ListView: Creates a scrollable, linear array of widgets from an explicit List. This constructor is appropriate for list views with a small number of children because constructing the List requires doing work for every child that could possibly be displayed in the list view instead of just those children that are actually visible.

ListView.builder: Creates a scrollable, linear array of widgets that are created on demand. This constructor 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.

Basically, builder constructor create a lazy list. When user is scrolling down the list, Flutter builds widgets "on demand".

Upvotes: 1

Related Questions