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.
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.
You can solve this problem in different way.
There are many answers here but I will put here the most important one which everyone should use.
1. Column
2. Wrap
You can use
Padding
widget in between those two widget or wrap those widgets withPadding
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:
Just use padding to wrap it like this:
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.
you can use
Wrap()
widget insteadColumn()
to add space between child widgets.And use spacing property to give equal spacing between childrenThere are many ways of doing it, I'm listing a few here.
Use
Container
and give some height:Use
Spacer
Use
Expanded
Use
mainAxisAlignment
Use
Wrap