Skip to content
Blog

Wrap Widget in Flutter: Designing Flexible Flow Layouts and Chip Groups

Mastering Flutter's Wrap widget to build dynamic tags, filter pills, and adaptive responsive buttons without triggering overflow errors.

Published on • November 1, 2026

AI Assistant

Every Flutter developer has encountered the dreaded yellow-and-black striped “A RenderFlex overflowed by X pixels” banner. This error typically happens when placing multiple horizontal children inside a standard Row, exceeding the available screen width.

When your children have varying or dynamic widths—such as category tags, filter chips, or action buttons—the Wrap widget is the standard solution (docs.flutter.dev).

How Wrap Works

Unlike a Row or Column which forces all children into a single non-wrapping line, Wrap lays out widgets sequentially along its main axis. When it runs out of space, it automatically wraps remaining children onto a new “run” along its cross axis.

Wrap(
  spacing: 8.0, // Gap between adjacent chips in the same row
  runSpacing: 12.0, // Gap between successive lines
  alignment: WrapAlignment.start,
  runAlignment: WrapAlignment.center,
  children: const [
    Chip(label: Text('Flutter')),
    Chip(label: Text('Dart 3.13')),
    Chip(label: Text('Impeller')),
    Chip(label: Text('WebAssembly')),
    Chip(label: Text('Generative UI')),
    Chip(label: Text('State Management')),
  ],
)

Essential Configuration Properties

1. direction

By default, Wrap lays out horizontally (Axis.horizontal). Setting direction: Axis.vertical creates columns that wrap horizontally when vertical space is exhausted.

2. spacing vs. runSpacing

  • spacing: Controls distance between items along the main axis.
  • runSpacing: Controls distance between parallel lines (the cross axis).

3. alignment and crossAxisAlignment

  • alignment: Defines how chips within each line align horizontally (e.g., WrapAlignment.center or WrapAlignment.spaceBetween).
  • crossAxisAlignment: Dictates how items of differing heights within a single line align against each other (e.g., baseline, start, center).

Real-World Use Cases

  • Filter & Search Pills: E-commerce catalog tags that adjust dynamically based on translated string lengths and device width.
  • Responsive Action Bars: Dialog action buttons that sit side-by-side on wide screens but stack gracefully on narrow phones.
  • User Profile Badges: Skill pills and hobby indicators on social profile views.

Wrap eliminates layout overflow bugs and creates fluid, adaptable interfaces across all form factors.