dartflutterflutter-layout

Space between Column's children in Flutter


I have a Column widget with two TextField widgets as children and I want to have some space between both of them.

I already tried mainAxisAlignment: MainAxisAlignment.spaceAround, but the result was not what I wanted.


Solution

  • You can use Padding widget in between those two widget or wrap those widgets with Padding widget.

    Update

    SizedBox widget can be use in between two widget to add space between two widget and it makes code more readable than padding widget.

    Ex:

    Column(
      children: <Widget>[
        Widget1(),
        SizedBox(height: 10),
        Widget2(),
      ],
    ),