In debug mode you see yellow and black stripes on the edge of a widget, and the console says:
A RenderFlex overflowed by 42 pixels on the right.
The relevant error-causing widget was:
Row Row:file:///.../lib/profile_card.dart:18:12
RenderFlex is what draws a Row or a Column. “On the right” means a Row is too wide; “on the bottom” means a Column is too tall. The file:line link points at the Row or Column, not at the child that is too big.
In release mode the stripes disappear, but the content is still cut off. Fix it; don’t hide it.
Why it happens
A Row gives each normal child as much width as the child asks for. A long Text, a wide image or a few buttons together can ask for more than the screen has, and the Row can’t squeeze them. A Column does the same vertically, which is why a form that fits on your phone overflows on a small one, or as soon as the keyboard opens.
The fix depends on which case you’re in.
Case 1: long text in a Row (overflow on the right)
Tell the Row which child is allowed to shrink. Expanded gives that child the leftover width, and the Text then cuts itself off with an ellipsis:
Row(
children: [
const Icon(Icons.person),
const SizedBox(width: 8),
Expanded(
child: Text(
user.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
TextButton(onPressed: onFollow, child: const Text('Follow')),
],
)
Use Flexible instead of Expanded when the text should take only the width it needs, so the button sits right after a short name instead of at the far end.
Case 2: a form or screen too tall (overflow on the bottom)
Make the Column scrollable. This also fixes the overflow that appears when the keyboard opens:
Scaffold(
body: SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
children: const [
TextField(decoration: InputDecoration(labelText: 'Email')),
SizedBox(height: 12),
TextField(decoration: InputDecoration(labelText: 'Password')),
],
),
),
),
)
Setting resizeToAvoidBottomInset: false on the Scaffold also makes the stripes go away, but the keyboard then covers your fields. Use it only for screens where nothing important sits low, like a full-screen camera view.
Case 3: chips or tags in a Row
If items should move to the next line instead of shrinking, use Wrap instead of Row:
Wrap(
spacing: 8,
runSpacing: 8,
children: [for (final tag in tags) Chip(label: Text(tag))],
)
Case 4: a list inside a Column
A ListView inside a Column needs a height. Expanded gives it the rest of the screen:
Column(
children: [
const SearchBar(),
Expanded(
child: ListView.builder(
itemCount: items.length,
itemBuilder: (context, i) => ListTile(title: Text(items[i])),
),
),
],
)
Without it you usually get a different error, “Vertical viewport was given unbounded height”, and adding shrinkWrap: true instead works but builds every item at once, which is slow for long lists.
What not to do
- Don’t hard-code widths and heights to make it fit on your phone. Test on a small screen (360 dp wide) and with a large system font size, which is where most overflows show up in production.
- Don’t wrap everything in
SingleChildScrollView. A horizontally scrolling Row hides the problem: users won’t know there’s more content. - Don’t use
FittedBoxon text to squeeze it. Text that shrinks to fit becomes unreadable on small phones.
To find which child is too big, open Flutter DevTools → Widget Inspector and select the Row or Column; the inspector shows each child’s size and constraints.
Frequently asked questions
What does "A RenderFlex overflowed by pixels on the right" mean?
A Row’s children are wider than the space the Row has, by that many pixels. Wrap the child that should shrink, usually a Text, in Expanded or Flexible and set overflow: TextOverflow.ellipsis on the Text.
Why does a RenderFlex overflow appear when the keyboard opens?
The keyboard reduces the height available to the Scaffold body, so a Column that fitted before is now too tall. Put the Column inside a SingleChildScrollView so it can scroll above the keyboard.
Does the overflow error show in release builds?
The yellow and black stripes and the console message only appear in debug mode. In release mode the content that does not fit is silently cut off, so users still see a broken layout.
What is the difference between Expanded and Flexible?
Expanded forces its child to fill all the leftover space in the Row or Column. Flexible lets the child be smaller than the leftover space, taking only what it needs, but never more. Both stop the child from overflowing.
Stuck on a build or a store release? I fix and maintain Flutter apps, or tell me about your project. More fixes: all Flutter answers.