Flutter Performance use ListView.builder() for list with a large amount of items Tips- 2

In this article I will share with you Listview tip We have more than one constructors in the ListView class and sometimes you maybe wondering which one to use in determined case.

 

ListView(children: [])

This is the default ListView's counstructor that takes a list of Widgets. We must use this in cases where we have a small list views items.

ListView.builder(...)

This is the constructor that we must use for cases that we have a large number of list view items because different than ListView(children: <Widget>[]) this constructor only build items that are visible in the screen. Each time the user scroll the list it build the next visible item.

ListView.separated(...)

This one do the same as the ListView.builder(...) but with a bonus: it takes an separatorBuilder to give us the ability to add a separator between our items.

Tags: