DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

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

Posted on

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)

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›