Categories
Flutter Mobile Development

How to center content vertically and horizontally

Centering content inside a column vertically and horizontally is something we need to do most of the time as app developers


Flutter makes this trivial. All you need to do is add 2 properties to Column object

  • mainAxisAlignment
  • crossAxisAlignment


I will talk more about the properties in a future post where we will discuss layouts.


Here is a code snippet to demonstrate how to use these properies

 Column(
    mainAxisAlignment: MainAxisAlignment.center,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: <Widget>[
      // more stuff..
    ]
  ),

Sign up to be notified of new posts. I promise i won’t spam you.

Leave a Reply

Your email address will not be published.