flutter-fix-layout-issues

Fixes Flutter layout errors (overflows, unbounded constraints) using Dart and Flutter MCP tools. Use when addressing "RenderFlex overflowed", "Vertical…

INSTALLATION
npx skills add https://github.com/flutter/skills --skill flutter-fix-layout-issues
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$27

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):

// 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):

// 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):

// Throws "An InputDecorator...cannot have an unbounded width"

Row(

  children: [

    const Icon(Icons.search),

    TextField(),

  ],

)

Output (Resolved State):

// 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):

// 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):

// 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.'),

    ),

  ],

)
BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card