Skip to content

Columns and Rows

These layout widgets are fundamental to Flutter UI development and understanding their properties is crucial for creating responsive and well-structured interfaces.

Flutter Column

A Column is a widget that displays its children in a vertical array. It’s one of the most fundamental layout widgets in Flutter.

AttributeDescriptionCommon Values
childrenThe widgets to display vertically[Widget1, Widget2, ...]
mainAxisAlignmentHow children should be placed along the main axis (vertical)MainAxisAlignment.start, center, end, spaceBetween, spaceAround, spaceEvenly
crossAxisAlignmentHow children should be placed along the cross axis (horizontal)CrossAxisAlignment.start, center, end, stretch
mainAxisSizeHow much space should be occupied in the main axisMainAxisSize.max, min
verticalDirectionThe order to lay children out verticallyVerticalDirection.down, up
textDirectionThe order to lay children out horizontallyTextDirection.ltr, rtl
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(width: 50, height: 50, color: Colors.red),
Container(width: 50, height: 50, color: Colors.green),
Container(width: 50, height: 50, color: Colors.blue),
],
)
flowchart TD
    subgraph ColumnAlignment[Column Alignment Types]
        direction TB
        Start[MainAxisAlignment.start
Children at top] --> CenterAlign[MainAxisAlignment.center
Children centered] --> End[MainAxisAlignment.end
Children at bottom] SpaceB[MainAxisAlignment.spaceBetween
Equal space between] --> SpaceA[MainAxisAlignment.spaceAround
Space around children] --> SpaceE[MainAxisAlignment.spaceEvenly
Equal space throughout] end
flowchart TD
 subgraph ColumnLayout[Column - Vertical Arrangement]
        direction TB
        Parent[Parent Container] --> ColumnWidget[Column Widget]

        subgraph MainAxis[Main Axis - Vertical]
            direction TB
            Child1[Child 1] --> Child2[Child 2] --> Child3[Child 3]
        end

        subgraph CrossAxis[Cross Axis - Horizontal]
            direction LR
            Left[Start] --> Center[Center] --> Right[End]
        end

        ColumnWidget --> MainAxis
        ColumnWidget --> CrossAxis

    end

A Row is a widget that displays its children in a horizontal array. It works similarly to Column but along the horizontal axis.

AttributeDescriptionCommon Values
childrenThe widgets to display horizontally[Widget1, Widget2, ...]
mainAxisAlignmentHow children should be placed along the main axis (horizontal)MainAxisAlignment.start, center, end, spaceBetween, spaceAround, spaceEvenly
crossAxisAlignmentHow children should be placed along the cross axis (vertical)CrossAxisAlignment.start, center, end, stretch, baseline
mainAxisSizeHow much space should be occupied in the main axisMainAxisSize.max, min
verticalDirectionThe order to lay children out verticallyVerticalDirection.down, up
textDirectionThe order to lay children out horizontallyTextDirection.ltr, rtl
textBaselineThe baseline to use for aligning textTextBaseline.alphabetic, ideographic
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(width: 50, height: 50, color: Colors.red),
Container(width: 50, height: 50, color: Colors.green),
Container(width: 50, height: 50, color: Colors.blue),
],
)
flowchart LR
    subgraph RowLayout[Row - Horizontal Arrangement]
        ParentR[Parent Container] --> RowWidget[Row Widget]

        subgraph MainAxisR[Main Axis - Horizontal]
            direction LR
            ChildR1[Child 1] --> ChildR2[Child 2] --> ChildR3[Child 3]
        end

        subgraph CrossAxisR[Cross Axis - Vertical]
            direction TB
            Top[Start] --> Middle[Center] --> Bottom[End]
        end

        RowWidget --> MainAxisR
        RowWidget --> CrossAxisR
    end

    subgraph RowAlignment[Row Alignment Types]
        direction LR
        StartR[MainAxisAlignment.start
Children at left] --> CenterAlignR[MainAxisAlignment.center
Children centered] --> EndR[MainAxisAlignment.end
Children at right] SpaceBR[MainAxisAlignment.spaceBetween
Equal space between] --> SpaceAR[MainAxisAlignment.spaceAround
Space around children] --> SpaceER[MainAxisAlignment.spaceEvenly
Equal space throughout] end
flowchart TD
    subgraph FlexProperties[Expanded Widget Properties]
        Flex1[Expanded flex: 1
Takes 1/5 of space] --> Flex2[Expanded flex: 3
Takes 3/5 of space] --> Flex3[Expanded flex: 1
Takes 1/5 of space] end
flowchart TD
    subgraph PracticalExample[Practical Column & Row Combination]
        direction TB

        MainColumn[Main Column] --> Header[Header Widget]
        MainColumn --> ContentRow[Content Row]
        MainColumn --> Footer[Footer Widget]

        subgraph ContentRowExpanded[Content Row Children]
            direction LR
            Sidebar[Sidebar Column
Expanded flex: 1] --> MainContent[Main Content Column
Expanded flex: 3] --> Ads[Ads Column
Expanded flex: 1] end ContentRow --> ContentRowExpanded end
AspectColumnRow
Primary AxisVertical (top to bottom)Horizontal (left to right)
Use CaseVertical lists, forms, stacked contentHorizontal lists, toolbars, tab bars
ScrollingUse ListView instead for scrollable contentUse ListView with horizontal scroll
Common ChildrenText, TextField, Button, ContainerIcon, Text, Button, Spacer

Both Column and Row work well with Expanded and Flexible widgets to create flexible layouts:

Column(
children: [
Expanded(
flex: 2, // Takes 2/5 of available space
child: Container(color: Colors.red),
),
Expanded(
flex: 3, // Takes 3/5 of available space
child: Row(
children: [
Flexible(child: Container(color: Colors.green)),
Flexible(child: Container(color: Colors.blue)),
],
),
),
],
)
  1. Overflow Errors: Use Expanded, Flexible, or SingleChildScrollView to handle content that might exceed available space
  2. Alignment Issues: Remember that crossAxisAlignment works perpendicular to the main axis
  3. Size Constraints: Columns and Rows respect their parent’s constraints, so ensure proper constraint propagation