Skip to main content
skill CX Codex

flutter-fix-layout-issues — Claude Code skill for Flutter layout

Reads a Flutter layout exception and tells you what to wrap in what: overflow stripes, unbounded constraints, misplaced ParentData widgets.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add flutter/agent-plugins --skill flutter-fix-layout-issues -a claude-code
Open on GitHub

What flutter-fix-layout-issues does

The skill builds on one rule of Flutter layout: constraints flow down, sizes come back up, the parent sets position. Break that deal and the console prints a signature you can match against. “Vertical viewport was given unbounded height” means a ListView or GridView sits inside a Column with no height limit. “An InputDecorator...cannot have an unbounded width” means a TextField landed in a Row and is measuring itself against infinite space. “RenderFlex overflowed” means a child asked for more than the parent granted; you see it as yellow and black stripes.

The workflow is a checklist. Run the app in debug mode, grab the first exception, and skip the cascading “RenderBox was not laid out” lines — the real cause sits higher in the stack. Each error type gets its own fix: wrap the scrollable in Expanded to take the leftover space or in SizedBox for a fixed height, wrap the text field in Expanded or Flexible, wrap the overflowing child in Expanded to force a fit or Flexible to let it shrink. Then hot reload and check that the red screen or the stripes are gone.

One more case is “Incorrect use of ParentData widget”: the widget has to be a direct child of the parent it needs. Expanded and Flexible belong directly under Row, Column or Flex; Positioned belongs directly under Stack. The skill is described as working through Dart and Flutter MCP tools, so without that MCP server connected the agent is down to the error text and the code on screen.

What it helps with

  • Clear yellow and black overflow stripes inside a Row or Column
  • Fix “Vertical viewport was given unbounded height” on a ListView in a Column
  • Constrain a TextField complaining about unbounded width
  • Find the primary error under cascading “RenderBox was not laid out” lines
  • Move Expanded or Positioned to be a direct child of its required parent

Example prompts for the agent

  • The console says RenderFlex overflowed — find the overflowing widget and wrap it in Expanded
  • Fix the layout: ListView inside Column gives unbounded height, it needs Expanded
  • Walk the stack trace and explain why Positioned triggers a ParentData error

How to install flutter-fix-layout-issues

1Skills CLI (Vercel)

npx skills add flutter/agent-plugins --skill flutter-fix-layout-issues -a claude-code

2Manually: put the files in place

~/.claude/skills/flutter-fix-layout-issues/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/flutter-fix-layout-issues/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about flutter-fix-layout-issues

How do I install flutter-fix-layout-issues in Claude Code?

Run npx skills add flutter/agent-plugins --skill flutter-fix-layout-issues -a claude-code. The skill lands at ~/.claude/skills/flutter-fix-layout-issues/SKILL.md.

What does flutter-fix-layout-issues do?

It matches a Flutter layout error to the kind of constraint violation and names the wrapper to add: Expanded, Flexible or SizedBox.

Which errors does it handle?

“Vertical viewport was given unbounded height”, “An InputDecorator...cannot have an unbounded width”, “RenderFlex overflowed” and “Incorrect use of ParentData widget”.

Source text

SKILL.md · BSD-3-Clause
---
name: flutter-fix-layout-issues
description: Fixes Flutter layout errors (overflows, unbounded constraints) using Dart and Flutter MCP tools. Use when addressing "RenderFlex overflowed", "Vertical viewport was given unbounded height", or similar layout issues.
metadata:
  model: models/gemini-3.1-pro-preview
  last_modified: Tue, 21 Apr 2026 19:45:59 GMT
---
# Resolving Flutter Layout Errors

## Contents
- [Constraint Violation Diagnostics](#constraint-violation-diagnostics)
- [Layout Error Resolution Workflow](#layout-error-resolution-workflow)
- [Examples](#examples)

## Constraint Violation Diagnostics

Flutter layout operates on a strict rule: **Constraints go down. Sizes go up. Parent sets position.** Layout errors occur when this negotiation fails, typically due to unbounded constraints or unconstrained children. 

Diagnose layout failures using the following error signatures:

*   **"Vertical viewport was given unbounded height"**: Triggered when a scrollable widget (`ListView`, `GridView`) is placed inside an unconstrained vertical parent (`Column`). The parent provides infinite height, and the child attempts to expand infinitely.
*   **"An InputDecorator...cannot have an unbounded width"**: Triggered when a `TextField` or `TextFormField` is placed inside an unconstrained horizontal parent (`Row`). The text field attempts to determine its width based on infinite available space.
*   **"RenderFlex overflowed"**: Triggered when a child of a `Row` or `Column` requests a size larger than the parent's allocated constraints. Visually indicated by yellow and black warning stripes.
*   **"Incorrect use of ParentData widget"**: Triggered when a `ParentDataWidget` is not a direct descendant of its required ancestor. (e.g., `Expanded` outside a `Flex`, `Positioned` outside a `Stack`).
*   **"RenderBox was not laid out"**: A cascading side-effect error. Ignore this and look further up the stack trace for the primary constraint violation (usually an unbounded height/width error).

## Layout Error Resolution Workflow

Copy and use this checklist to systematically resolve layout constraint violations.

### Task Progress
- [ ] Run the application in debug mode to capture the exact layout exception in the console.
- [ ] Identify the primary error message (ignore cascading "RenderBox was not laid out" errors).
- [ ] Apply the conditional fix based on the specific error type:
  - **If "Vertical viewport was given unbounded height"**: Wrap the scrollable child (`ListView`, `GridView`) in an `Expanded` widget to consume remaining space, or wrap it in a `SizedBox` to provide an absolute height constraint.
  - **If "An InputDecorator...cannot have an unbounded width"**: Wrap the `TextField` or `TextFormField` in an `Expanded` or `Flexible` widget.
  - **If "RenderFlex overflowed"**: Constrain the overflowing child by wrapping it in an `Expanded` widget (to force it to fit) or a `Flexible` widget (to allow it to be smaller than the allocated space).
  - **If "Incorrect use of ParentData widget"**: Move the `ParentDataWidget` to be a direct child of its required parent. Ensure `Expanded`/`Flexible` are direct children of `Row`/`Column`/`Flex`. Ensure `Positioned` is a direct child of `Stack`.
- [ ] Execute Flutter hot reload.
- [ ] Run validator -> review errors -> fix: Inspect the UI to verify the red/grey error screen or yellow/black overflow stripes are resolved. If new layout errors appear, repeat the workflow.

## Examples

### Fixing Unbounded Height (ListView in Column)

**Input (Error State):**
```dart
// Throws "Vertical viewport was given unbounded height"
Column(
  children: <Widget>[
    const Text('Header'),
    ListView(
      children: const <Widget>[
        ListTile(title: Text('Item 1')),
        ListTile(title: Text('Item 2')),
      ],
    ),
  ],
)
```

**Output (Resolved State):**
```dart
// Wrap ListView in Expanded to constrain its height to the remaining Column space
Column(
  children: <Widget>[
    const Text('Header'),
    Expanded(
      child: ListView(
        children: const <Widget>[
          ListTile(title: Text('Item 1')),
          ListTile(title: Text('Item 2')),
        ],
      ),
    ),
  ],
)
```

### Fixing Unbounded Width (TextField in Row)

**Input (Error State):**
```dart
// Throws "An InputDecorator...cannot have an unbounded width"
Row(
  children: [
    const Icon(Icons.search),
    TextField(), 
  ],
)
```

**Output (Resolved State):**
```dart
// Wrap TextField in Expanded to constrain its width to the remaining Row space
Row(
  children: [
    const Icon(Icons.search),
    Expanded(
      child: TextField(),
    ),
  ],
)
```

### Fixing RenderFlex Overflow

**Input (Error State):**
```dart
// Throws "A RenderFlex overflowed by X pixels on the right"
Row(
  children: [
    const Icon(Icons.info),
    const Text('This is a very long text string that will definitely overflow the available screen width and cause a RenderFlex error.'),
  ],
)
```

**Output (Resolved State):**
```dart
// Wrap the Text widget in Expanded to force it to wrap within the available constraints
Row(
  children: [
    const Icon(Icons.info),
    Expanded(
      child: const Text('This is a very long text string that will definitely overflow the available screen width and cause a RenderFlex error.'),
    ),
  ],
)
```

© flutter · BSD-3-Clause · flutter/agent-plugins

Similar skills

Everything for Mobile →

From the same set15

The whole set →
flutter-apply-architecture-best-practices This skill structures Flutter apps around UI, Logic, and Data layers. Use it when starting a project or refactoring code for scale. CX Codex +1 43,200installs flutter-build-responsive-layout This skill guides coding agents to build adaptive Flutter UIs across mobile and desktop screens using LayoutBuilder and BoxConstraints. CX Codex +1 42,500installs flutter-add-widget-test A skill that teaches AI coders to write component-level Flutter tests using WidgetTester. Verifies how widgets render and respond to taps, scrolling, and text input. CX Codex +1 39,200installs flutter-add-integration-test Sets up the integration_test package for Flutter and turns MCP session interactions into repeatable end-to-end tests. CX Codex +1 38,200installs flutter-setup-declarative-routing Sets up Flutter routing with go_router, including URL-based screens, nested navigation, and deep links for web and mobile apps. CX Codex +1 37,800installs flutter-implement-json-serialization Teaches coding agents to build Dart models with fromJson and toJson methods using dart:convert. Useful for manual JSON mapping in simple Flutter data structures. CX Codex +1 37,400installs flutter-add-widget-preview Configures interactive Flutter widget previews with package:flutter/widget_previews.dart. Useful for testing UI components in isolation without launching the whole app. CX Codex +1 36,800installs flutter-setup-localization This skill automates initialization of multi-language support in Flutter projects. It adds dependencies, enables code generation, and creates a configuration file for .arb-based translations. CX Codex +1 36,800installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor