Flutter · One codebase, native feel

How do you keep long lists smooth?

Mediumlistsperformancelazy loadingrebuildsUpdated Oct 2026
Quiz this track

Short answer

Build lazily with ListView.builder, give items stable keys, keep item widgets cheap and const where possible, and avoid shrinkWrap or unbounded intrinsic measurement on long lists.

A ListView constructs only the children near the viewport when it can estimate extent. ListView.builder does that by default. Fixed extents make scrolling and jump-to-index cheaper because the viewport does not need to measure every child. Large images should be decoded at display size rather than full resolution.

dart
ListView.builder(
  itemCount: messages.length,
  itemExtent: 72,
  itemBuilder: (context, index) {
    final message = messages[index];
    return MessageTile(key: ValueKey(message.id), message: message);
  },
)
  • Use itemExtent or prototypeItem when rows share a predictable height
  • Avoid shrinkWrap inside another scrollable on long content
  • Add pagination or infinite scrolling instead of loading thousands of rows at once
  • Use const widgets and split large rows so rebuilds stay local
  • Pass cacheWidth to Image.network for thumbnails
  • Avoid work in itemBuilder such as sorting the whole list on every row

What to measure

Profile in profile mode and inspect frame timings while scrolling. Distinguish UI-thread time spent building rows from raster time spent drawing images or shadows. Rebuild counts help find a row that rebuilds on every frame. If images dominate, resize and cache them; if building dominates, simplify the row widget.

Slivers give finer control for mixed content such as headers, grids and lists in one scroll view. They are worth the complexity when a single ListView cannot express the screen efficiently.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1Why is shrinkWrap expensive on a long list?
  2. 2How does itemExtent improve scrolling performance?
  3. 3How would you paginate a list without duplicating items?
  4. 4What would you check if rows rebuild on every scroll frame?

Say it in the interview

For long lists I use ListView.builder so children are created lazily, and I give each row a stable key. If row heights are predictable I set itemExtent, which helps scrolling and jumps. I keep rows cheap, decode images at the right size, and paginate instead of loading everything. Then I profile scrolling and look separately at UI-thread rebuild cost and raster cost.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Flutter mock interview and get scored feedback on depth, clarity and confidence.