Skip to main content

Wrap

The Wrap widget is a layout container that lays children out in one direction and automatically moves them to the next line — a row or a column — when space runs out.
Use it for items whose count varies, such as buttons, tags, and chips, so they flow naturally within the available width.

Definition and role

The Wrap widget arranges children along the direction you set (direction), then wraps to the next line as soon as they no longer fit in the remaining space. Unlike Row and Column, it never clips or pushes out an overflowing child — it flows the child onto the next line instead. Set the spacing between items (spacing), the spacing between lines (runSpacing), and the alignment independently.

  • Category: Layouts
  • Default layout direction: horizontal (horizontal)
  • Default item spacing and line spacing: 0

Features

FeatureDescription
Automatic wrappingLays children out along the layout direction, then moves them to the next line (row or column) when space runs out.
Layout directionUse direction to choose a horizontal flow, where lines stack downward, or a vertical flow, where lines stack sideways.
SpacingSet the spacing between items (spacing) and the spacing between lines (runSpacing) separately.
AlignmentAdjust the alignment inside a line (alignment), the alignment of the lines themselves (runAlignment), and the cross-axis alignment (crossAxisAlignment) independently.

How to use

  1. Open the Layouts category in the left widget palette.
  2. Drag and drop the Wrap item onto the canvas.
  3. Add the child widgets you want to lay out inside the Wrap.
  4. In the properties panel on the right, set the layout direction with direction and the spacing with spacing and runSpacing.
  5. If needed, fine-tune the alignment with alignment, runAlignment, and crossAxisAlignment.

Properties

PropertyDescriptionDefaultValue / Type
directionMain direction children are laid out inhorizontalhorizontal, vertical
alignmentMain-axis alignment inside a single linestartstart, end, center, spaceBetween, spaceAround, spaceEvenly
spacingSpacing between items on the same line0Number
runAlignmentAligns the lines (runs) along the cross axisstartstart, end, center, spaceBetween, spaceAround, spaceEvenly
runSpacingSpacing between one line and the next0Number
crossAxisAlignmentCross-axis alignment inside a single linestartstart, end, center
textDirectionLeft-to-right direction children are placed in for a horizontal layoutNot setrtl, ltr
verticalDirectionOrder children and lines stack in verticallydownup, down
clipBehaviorHow content that extends past the area is clipped — this doesn't work in the current version.nonenone, hardEdge, antiAlias, antiAliasWithSaveLayer

Notes and tips

tip

spacing and runSpacing are different: spacing is the gap between items on the same line, and runSpacing is the gap between one line and the next. Adjust both so your items don't bunch up.

note

When direction is horizontal, lines stack from top to bottom; when it's vertical, lines stack from left to right. Use verticalDirection to reverse the stacking order.

Learn more

tip

For the full set of Widget Controls (Property, Method, and Event) that let you drive this widget from a script, see Wrap Widget Control.