ListView
Learn about the ListView widget in Flutter, which builds the child widgets one after the other and also makes them scrollable.
We'll cover the following
Just like Column
and Row
widgets, ListView
widgets are used to arrange the children in a list. The children of ListView
are scrollable by default.
There are two ways to construct a list of widgets in Flutter. One is simple ListView
, which will take the children
property just like Column
or Row
, and the other is ListView.builder
, which will take a function itemBuilder(int index)
. Based on that index, we can build common or custom widgets for each index. For the ListView.builder
, we have to provide the size of the list we’re going to build.
Generally, we use ListView
for smaller size lists and ListView.builder
for larger lists because ListView.builder
builds the child
widgets on the go when they are about to be visible on screen, thus saving resources, unlike the normal ListView
constructor.
In the example below, we’ll build a list of widgets with the ListView.builder
constructor:
Get hands-on with 1400+ tech skills courses.