Space between Column's children in Flutter

后端 未结 14 824
刺人心
刺人心 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条回答
  •  猫巷女王i
    2021-02-02 05:29

    Just use padding to wrap it like this:

    Column(
      children: [
      Padding(
        padding: EdgeInsets.all(8.0),
        child: Text('Hello World!'),
      ),
      Padding(
        padding: EdgeInsets.all(8.0),
        child: Text('Hello World2!'),
      )
    ]);
    

    You can also use Container(padding...) or SizeBox(height: x.x). The last one is the most common but it will depents of how you want to manage the space of your widgets, I like to use padding if the space is part of the widget indeed and use sizebox for lists for example.

提交回复
热议问题