# Flutter Errors

> Use when hitting layout errors (RenderFlex overflow, unbounded constraints, RenderBox not laid out), scroll errors, or setState-during-build errors.

- **Type:** Skill
- **Install:** `agentstack add skill-evanca-flutter-ai-rules-flutter-errors`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [evanca](https://agentstack.voostack.com/s/evanca)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [evanca](https://github.com/evanca)
- **Source:** https://github.com/evanca/flutter-ai-rules/tree/main/skills/flutter-errors

## Install

```sh
agentstack add skill-evanca-flutter-ai-rules-flutter-errors
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Flutter Errors Skill

This skill provides solutions for the most common Flutter runtime and layout errors.

---

## RenderFlex Overflowed

**Error:** `A RenderFlex overflowed by X pixels on the right/bottom.`

**Cause:** A `Row` or `Column` contains children that are wider/taller than the available space.

**Fix:** Wrap the overflowing child in `Flexible` or `Expanded`, or constrain its size:

```dart
Row(
  children: [
    Expanded(child: Text('Long text that might overflow')),
    Icon(Icons.info),
  ],
)
```

---

## Vertical Viewport Given Unbounded Height

**Error:** `Vertical viewport was given unbounded height.`

**Cause:** A `ListView` (or other scrollable) is placed inside a `Column` without a bounded height.

**Fix:** Wrap the `ListView` in `Expanded` or give it a fixed height with `SizedBox`:

```dart
Column(
  children: [
    Text('Header'),
    Expanded(
      child: ListView(children: [...]),
    ),
  ],
)
```

---

## InputDecorator Cannot Have Unbounded Width

**Error:** `An InputDecorator...cannot have an unbounded width.`

**Cause:** A `TextField` or similar widget is placed in a context without width constraints.

**Fix:** Wrap it in `Expanded`, `SizedBox`, or any parent that provides width constraints:

```dart
Row(
  children: [
    Expanded(child: TextField()),
  ],
)
```

---

## setState Called During Build

**Error:** `setState() or markNeedsBuild() called during build.`

**Cause:** `setState` or `showDialog` is called directly inside the `build` method.

**Fix:** Trigger state changes in response to user actions, or defer to after the frame using `addPostFrameCallback`:

```dart
@override
void initState() {
  super.initState();
  WidgetsBinding.instance.addPostFrameCallback((_) {
    // Safe to call setState or showDialog here
  });
}
```

---

## ScrollController Attached to Multiple Scroll Views

**Error:** `The ScrollController is attached to multiple scroll views.`

**Cause:** A single `ScrollController` instance is shared across more than one scrollable widget simultaneously.

**Fix:** Ensure each scrollable widget has its own dedicated `ScrollController` instance.

---

## RenderBox Was Not Laid Out

**Error:** `RenderBox was not laid out: ...`

**Cause:** A widget is missing or has unbounded constraints — commonly `ListView` or `Column` without proper size constraints.

**Fix:** Review your widget tree for missing constraints. Common patterns:

- Wrap `ListView` in `Expanded` inside a `Column`.
- Give widgets an explicit `width` or `height` via `SizedBox` or `ConstrainedBox`.

---

## Debugging Layout Issues

- Use the **Flutter Inspector** (in DevTools) to visualize widget constraints.
- Enable **"Show guidelines"** to see layout boundaries.
- Add `debugPaintSizeEnabled = true;` temporarily in your `main()` to paint layout bounds.
- Refer to the [Flutter constraints documentation](https://docs.flutter.dev/ui/layout/constraints) for a deeper understanding of how constraints propagate.

## References

- [Flutter Website GitHub Repository](https://github.com/flutter/website)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [evanca](https://github.com/evanca)
- **Source:** [evanca/flutter-ai-rules](https://github.com/evanca/flutter-ai-rules)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-evanca-flutter-ai-rules-flutter-errors
- Seller: https://agentstack.voostack.com/s/evanca
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
