Space between Column's children in Flutter

后端 未结 14 822
刺人心
刺人心 2021-02-02 04:33

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 mainAxi

14条回答
  •  爱一瞬间的悲伤
    2021-02-02 05:11

    There are many answers here but I will put here the most important one which everyone should use.

    1. Column

     Column(
              children: [
                Text('Widget A'), //Can be any widget
                SizedBox(height: 20,), //height is space betweeen your top and bottom widget
                Text('Widget B'), //Can be any widget
              ],
            ),
    

    2. Wrap

         Wrap(
              direction: Axis.vertical, // We have to declare Axis.vertical, otherwise by default widget are drawn in horizontal order
                spacing: 20, // Add spacing one time which is same for all other widgets in the children list
                children: [
                  Text('Widget A'), // Can be any widget
                  Text('Widget B'), // Can be any widget
                ]
            )
    

提交回复
热议问题