Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

A Flutter Row or Column shows yellow and black stripes and says it overflowed

ErrorA RenderFlex overflowed by 143 pixels on the right.

Short answer

A RenderFlex is a Row or Column. It overflows when a child asks for more space than the Row or Column can give. Find the widget named in the error, then wrap the greedy child in Expanded or Flexible, let a tall Column scroll, or use Wrap so children move to the next line.

  • Applies to Flutter 3.35, Dart 3.9
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the first lines of the error in the debug console. It names the Row or Column and the file and line, and says whether the overflow is horizontal or vertical. That tells you which cause below applies.

    flutter run -d chrome   # or any device; read the 'relevant error-causing widget' lines in the console
  2. 2Match what you see, then jump to its fix

    1. 1Axis.horizontal, and the stripes are on the right edgeA child of a Row is wider than the space left (long Text, Column or image)Fix
    2. 2Axis.vertical, and the stripes are on the bottom edgeA Column is taller than the screen (small phone, keyboard open, landscape)Fix
    3. 3Axis.horizontal with several small siblings of fixed widthA row of chips, tags or buttons that should flow onto the next lineFix

What does the error look like?

  • A RenderFlex overflowed by 143 pixels on the right.
  • The overflowing RenderFlex has an orientation of Axis.horizontal.
  • A yellow and black striped pattern on the edge of the screen

Cause 1 of 3

A child of a Row is wider than the space left (long Text, Column or image)

1Check

A Row does not limit the width of its children. A Text with a long string, or a Column holding such a Text, takes the width of the whole string and pushes past the edge.

// Look for a Row whose child is not wrapped in Expanded or Flexible
Row(children: [
  Icon(Icons.message),
  Column(children: [Text('a very long title'), Text('a very long body ...')]),
])

2Fix

Wrap the greedy child in Expanded so it gets only the width that is left. Flexible does the same and lets the child be smaller than that space.

Row(children: [
  const Icon(Icons.message),
  Expanded(
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: const [Text('a very long title'), Text('a very long body ...')],
    ),
  ),
])

3Verify

Hot reload. The stripes are gone and the long text now wraps inside the space it has.

# press r in the flutter run terminal

Confirmed by docs.flutter.dev

Did this fix it?

Cause 2 of 3

A Column is taller than the screen (small phone, keyboard open, landscape)

1Check

A Column with fixed or tall children does not scroll by itself. When the screen gets shorter than the content, the extra height has nowhere to go.

flutter run   # rotate the device, or open the keyboard, and watch whether the stripes appear

2Fix

Put the Column inside a SingleChildScrollView so it scrolls when the space is too small. Do not use Expanded or Flexible inside a Column that sits in a scroll view: the available space there is infinite.

SingleChildScrollView(
  child: Column(
    children: const [Text('header'), SizedBox(height: 400), Text('footer')],
  ),
)

3Verify

Rotate the device or open the keyboard again: the page scrolls and no stripes show.

# repeat the step that caused the overflow

Confirmed by api.flutter.dev

Did this fix it?

Cause 3 of 3

A row of chips, tags or buttons that should flow onto the next line

1Check

A Row puts every child in one line, however many there are. If the number of items changes at run time, a fixed line will overflow sooner or later.

// Look for Row(children: items.map(...).toList()) with a variable number of items
grep -rn "Row(" lib/

2Fix

Use Wrap. It starts a new run when the line is full. Set spacing for the gap inside a run and runSpacing for the gap between runs.

Wrap(
  spacing: 8,
  runSpacing: 8,
  children: tags.map((t) => Chip(label: Text(t))).toList(),
)

3Verify

Add more items than fit on one line. They continue on a second line.

# hot reload and add items

Confirmed by api.flutter.dev

Did this fix it?

How do I stop it coming back?

  • Wrap any Text that sits next to other widgets in a Row with Expanded or Flexible from the start.
  • Test every screen once on a small phone size, in landscape and with the keyboard open.
  • Use ListView instead of a long Column when the number of items is not fixed.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.