Row Widget

A widget that displays its children in a horizontal array.

Row(
	children : <Widget>[
		Text("Hi"),
		Text("Hello"),
	],
),

The Row widget doesn't scroll. If you need scrolling, instead of Row widget, consider using ListView widget.

The children of Row widget can have two types of widget, they can be non-flexible or flexible. Non-flexible means their size is constant and doesn't expand, they takes space as much as they need. But Flexible widget can expand their width or height in order to fill the available space of the row.

In general it is considered an error to have more children in a row than will fit in the available room. If the non-flexible contents of the Row are together wider than the row itself, then the row is said to have overflowed. When a row overflows, the row doesn't have any remainin space to share between its expanded and Flexible children. The Row reports this by drawing a yellow and black stripped warning box on the edge that is overflowing.

When Row widget layouts its children, it follows the following steps :

So, the Row widget gives the proper size to the non-flexible child first, after that if there's remaining space is available, it is divided to the flexible children accroding to their flex factor. If there's no space available to distribute, it will give error.

So the best practice is to use Flexible widget to fill the available space of the Row widget and make sure in any way the Row doesn't get overflowed.

Here are some arguments you can use to control the Row widget:

mainAxisAlignment

This argument specifies how the children should be placed along the main axis in a flex layout. Use MainAxisAlignment class to provide the value. For Row widget the main axis is from left edge to right edge. The class MainAxisAlignment defines the following constant -

The following pictures explain each constants visually :

crossAxisAlignment

This represents how the children should be placed along the cross axis in a flex layout. Use CrossAxisAlignment class to provide the value. For Row widget the cross axis is from top to bottom. This class defines the following constants -

The following pictures explain each constants visually :

mainAxisSize

This argument is used to control the width of the Row n the main axis. After allocating space to children, there might be some remaining free space. This argument is used to control wheater to maximize or minimize the amount of free space. This argument is useless when you use flexible or Expanded children in the Row widget, since the Flexible or Expanded children will leave no remaining space and it will make the Row widget to have maximum width always. Use the class MainAxisSize to provide the value. This class defines the following two constants -

By default Row widget tries to be as big as possible. That is the default value is **max**

The following pictures explain each constants visually :