what are the differences between ListView.builder and use map function


What are the differences between ListView.builder and the map function when creating list of widgets? and when should we use one over the other?.


if you have a long list of items, use ListView.builder(). it only build items that are visible in the screen. Each time the user scrolls the list it builds the next visible item.

if you use

    children: items.map((items){
        return ...

it has a heavy build cost.

so, the best practice in my opinion is that use ListView.builder() .
you could use map
if you are sure the items are not more than a few items.

Answered By – Xoltawn

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *