Flutter Row Widget Examples

A row can display its children in a horizontal array. If you want to display widget into columns or display an icon to the left of a label, you can use Flutter Row widget.

Row with 3 columns and aligned and spaced evenly with MainAxisAlignment.spaceAround.

Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          Container(
            width: 100,
            height: 100,
            color: Colors.blue,
          ),Container(
            width: 100,
            height: 100,
            color: Colors.red,
          ),Container(
            width: 100,
            height: 100,
            color: Colors.green,
          ),
        ],
      )

Row with 3 containers which are stretched to fit screen’s height with CrossAxisAlignment.stretch.

Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          Container(
            width: 100,
            color: Colors.blue,
          ),Container(
            width: 100,
            color: Colors.red,
          ),Container(
            width: 100,
            color: Colors.green,
          ),
        ],
      )

We can use Row in a button to include multiple widgets.

OutlinedButton(
          onPressed: () {  },
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Icon(Icons.add),
              SizedBox(width: 16),
              Text('Add')
            ],
          ),
        )

Leave a Comment

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


Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close