Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    Column

    A vertical container — lays out its children from top to bottom.

    Type: multi-child

    Column spacing:16
      Text "First"
      Text "Second"

    Parameters

    Parameter Type Default Description
    alignment string start Alignment along the main axis: start , end , center , spaceBetween , spaceAround , spaceEvenly
    size string max Size along the main axis: min , max
    crossAlignment string center Alignment along the cross axis: start , end , center , stretch , baseline
    textDirection string — Text direction: ltr , rtl
    textBaseline string — Text baseline: alphabetic , ideographic
    spacing double 0 Space between children

    Examples

    Centered list

    Column mainAxisAlignment:center crossAxisAlignment:center spacing:16
      Text "Title"
      Text "Subtitle"
      ElevatedButton onPressed:"navigate:/home"
        Text "Get started"

    Stretched children

    Column crossAxisAlignment:stretch spacing:8
      Text "Field 1"
      Text "Field 2"
      ElevatedButton onPressed:"form:submit"
        Text "Submit"

    Best practices

    size:min inside scroll views

    By default a Column has mainAxisSize:max — it tries to take all the available space along the main axis. Inside a vertical scroll view ( CustomScrollView , SingleChildScrollView , ListView ) that space is infinite: "take all of it" is impossible, and there is nothing "left over" to share between Expanded and Spacer . A Column with a flexible child inside a scroll view is a layout error.

    Inside a vertical scroll view write size:min and do not put Expanded / Spacer along the vertical axis:

    // BAD — Spacer asks for "the remaining space", and in a scroll view it is infinite
    CustomScrollView
      Column crossAxisAlignment:stretch
        Text "Header"
        Spacer
        Text "Footer"
    
    // GOOD — the Column takes the height of its children, the gap is a number
    CustomScrollView
      Column crossAxisAlignment:stretch size:min spacing:24
        Text "Header"
        Text "Footer"

    The children of a CustomScrollView are page sections: each takes its own height and scrolls along with the rest. A long list of similar items inside it is a SliverList.builder , not a Column with a hundred children: a sliver builds only the rows the scroll has reached.

    Along the cross axis the constraint is the usual one: crossAxisAlignment:stretch inside a vertical scroll view works as it does everywhere.

    See also

    • Row — the horizontal counterpart
    • Expanded — stretching children inside a Column
    • Spacer — a flexible gap between elements