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

twitter logo github logo ・1 min read

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.

twitter logo DISCUSS
Classic DEV Post from Oct 8 '18

Start-up v Corporate, which do you prefer?

Becoming a Corporate is bad, staying a Start-up forever is good. Or is it?

Pedro Massango profile image
Flutter & Android