October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Center Widgets Inside a Flutter Column

Use crossAxisAlignment to center Column children horizontally and mainAxisAlignment to center them vertically when the column has finite free space.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To center every child horizontally in a Flutter Column, set crossAxisAlignment: CrossAxisAlignment.center—the default. To center the children vertically as a group, use mainAxisAlignment: MainAxisAlignment.center and give the column finite height with unused space to distribute. The two properties control different axes.

Which alignment property should you use?

A Column arranges children from top to bottom. Its main axis is vertical; its cross axis is horizontal. Choose the property that matches the direction you want to control.

As an Amazon Associate I earn from qualifying purchases.

Goal Property or widget Effect
Center all children horizontally crossAxisAlignment: CrossAxisAlignment.center Centers children on the horizontal cross axis. This is the default. Flutter Column documentation and CrossAxisAlignment API
Align children to the start or end horizontally CrossAxisAlignment.start or CrossAxisAlignment.end Places children at the cross-axis start or end; the precise direction depends on text direction. CrossAxisAlignment API
Make children fill the available width CrossAxisAlignment.stretch Gives children tight constraints across the cross axis; this is sizing, not centering. CrossAxisAlignment API
Center the children vertically as a group mainAxisAlignment: MainAxisAlignment.center Positions the group in the vertical main axis when the column has free height. Flutter Column documentation and MainAxisAlignment API
Distribute children vertically MainAxisAlignment.spaceBetween, .spaceAround, or .spaceEvenly Distributes available main-axis free space in different ways. MainAxisAlignment API
Position a single child Center or Align Positions one child within its available space. Flutter Column documentation

Center children horizontally

For horizontal centering, set crossAxisAlignment. Because the default is already CrossAxisAlignment.center, you can omit it unless making the intent explicit helps readability.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Column(
  crossAxisAlignment: CrossAxisAlignment.center,
  children: const [
    Text('First'),
    Text('Second'),
  ],
)

Each child is centered across the column’s width. If you use CrossAxisAlignment.stretch instead, children are given tight cross-axis constraints to fill that space, so they will not behave like naturally sized, horizontally centered children.

Center children vertically as a group

Use mainAxisAlignment: MainAxisAlignment.center to place the children together in the middle of the column’s vertical space:

Column(
  mainAxisAlignment: MainAxisAlignment.center,
  children: const [
    Text('First'),
    Text('Second'),
  ],
)

This works visibly only if the column has unused vertical space. If it is only as tall as the combined height of its children, there is no extra space in which to center the group.

Why vertical centering may not appear

The column has no extra height

mainAxisSize controls whether the column tries to occupy the maximum height allowed by its constraints or shrink to the combined size of its children. With MainAxisSize.min, the column shrink-wraps its children subject to those constraints; with MainAxisSize.max, it takes the maximum permitted height. Main-axis alignment distributes or positions children within whatever free space remains.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The parent does not provide a finite height

A column can center children vertically only when its constraints leave it finite free height. A column in a vertically unbounded context, such as a ListView, cannot divide an infinite amount of remaining height among flex children. A non-zero flex child such as Expanded may therefore cause a runtime exception.

If a nested column should occupy the remaining height, constrain it so that remaining space is finite. In a scrolling context with no finite remaining height, remove flex children rather than asking them to expand into unbounded space. The appropriate fix depends on whether the content is meant to fill a bounded area or scroll.

The children are taller than the available space

A Column does not scroll. If its contents exceed the available height, it can overflow; when the content should scroll, Flutter points to ListView as the usual alternative.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Center just one child

If only one widget needs positioning, use Center or Align rather than changing the alignment of every child in the column.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Center(
  child: Text('Centered child'),
)

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.