Flutter Row MainAxisAlignment Properties Explained with Example

In today’s tutorial we would learn about MainAxisAlignment and its properties along with Row widget. Row widget is used to set given widgets or items into a single Row format. Today we would learn about MainAxisAlignment which is used to set all the children array in horizontal format. The MainAxisAlignment has 6 different properties named as start, center, end, space around, space between and space evenly. We would learn about all of them in today’s tutorial. Flutter Row MainAxisAlignment Properties Explained with Example in Android iOS.

Contents in this project Flutter Row MainAxisAlignment Properties Explained with Example:

Note:- Given below all the examples is with CrossAxisAlignment.center in Row widget.

1. MainAxisAlignment.start :- Place all the given children as close at the start as possible to main axis.

2. MainAxisAlignment.center :- Place all the children of Row widget in center as close as possible.

3. MainAxisAlignment.end :- Place the children as close as to the end of main axis.

4. MainAxisAlignment.spaceAround :- Place the free space evenly between the children widget as well as half of that space before and after the first and last child widget.

5. MainAxisAlignment.spaceBetween :- Place the free space evenly between the children widget.

6. MainAxisAlignment.spaceEvenly :- Place the free space evenly between the children widget as well as before and after the first widget and last child widget.

7. Complete source code for main.dart file:


 

Leave a Reply

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