D
PerformanceBeginner10 XP2 min read

Why should you use ListView.builder instead of ListView for large lists?

TL;DR: ListView.builder builds only the visible items lazily. ListView() with a children: list builds all items upfront, causing jank and high memory usage with 100+ items.

Full Answer

AspectListView(children: [...])ListView.builder()
Item creationAll at once on first buildOn-demand as they scroll into view
MemoryAll items in memoryOnly visible + buffer
Good for< 20 static itemsAny dynamically-sized or long list
itemCountNot neededProvide for correct scroll extent
๐ŸŽฏ

For items of varying height, use ListView.builder with cacheExtent to pre-render items just outside the viewport and avoid layout jank during fast scrolling.

Code Examples

dartListView vs ListView.builder
Output
// ListView.builder: 1000 items scroll at 60fps
// ListView(children): potential jank on initial build

Common Mistakes

  • โœ—Using ListView(children: []) inside a Column โ€” causes 'Vertical viewport was given unbounded height' error
  • โœ—Setting itemCount too low and missing items

Interview Tip

๐Ÿ’ก

Mention that ListView.builder is backed by SliverList + SliverChildBuilderDelegate internally. Show you know the Sliver layer that powers Flutter's scrolling.

#listview-builder#lazy-loading#viewport#recycling