DEV Community

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

Posted on

6 3

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

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.

Top comments (0)

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more