Overview
Row is a layout control that displays its children in a horizontal array. Children are positioned from left to right in the order they appear in the controls list. To cause a child control to expand and fill the available horizontal space, set itsexpand property.
Basic Example
Class Definition
Properties
controls
A list of controls to display horizontally. Controls are arranged from left to right in the order they appear in the list.
alignment
Defines how the child controls should be placed horizontally along the main (horizontal) axis.Options:
MainAxisAlignment.START- Place children at the leftMainAxisAlignment.END- Place children at the rightMainAxisAlignment.CENTER- Place children in the middleMainAxisAlignment.SPACE_BETWEEN- Place free space evenly between childrenMainAxisAlignment.SPACE_AROUND- Place free space evenly between children and half of that space before and afterMainAxisAlignment.SPACE_EVENLY- Place free space evenly between children and before/after the first/last child
vertical_alignment
Defines how the child controls should be placed vertically along the cross (vertical) axis.Options:
CrossAxisAlignment.START- Align children to the topCrossAxisAlignment.END- Align children to the bottomCrossAxisAlignment.CENTER- Center children verticallyCrossAxisAlignment.STRETCH- Stretch children to fill vertical spaceCrossAxisAlignment.BASELINE- Align children by their text baseline
spacing
The spacing (in pixels) between the child controls.
This property only has effect when
alignment is MainAxisAlignment.START, MainAxisAlignment.END, or MainAxisAlignment.CENTER.tight
Whether this row should occupy all available horizontal space (
True), or only as much as needed by its children controls (False).This property only has effect when
wrap is False.wrap
Whether this row should put child controls into additional rows (runs) if they don’t fit in a single row.When
True, controls that exceed the available width will wrap vertically into additional rows.run_spacing
The spacing (in pixels) between runs when
wrap is True.This controls the vertical spacing between rows when wrapping occurs.run_alignment
How the runs should be placed in the cross-axis when
wrap is True.This controls how multiple rows are aligned vertically when wrapping is enabled.intrinsic_height
Whether this row should be as tall as the tallest child control in
controls.If False, the Row expands to fill the available height.Layout Behavior
How Children Are Arranged
-
Main Axis (Horizontal): Children are placed from left to right along the horizontal axis according to the
alignmentproperty. -
Cross Axis (Vertical): Children are aligned vertically according to the
vertical_alignmentproperty. -
Spacing: The
spacingproperty adds horizontal gaps between children when using START, END, or CENTER alignment. -
Wrapping: When
wrapis enabled, children that don’t fit horizontally will wrap into new rows below.
Expanding Children
Set theexpand property on child controls to make them fill available horizontal space:
Scrolling
Row inherits fromScrollableControl, which means it can be made scrollable: