I don’t want the button to be in the centre instead of that I want to change the location of the button to the right and I don’t know how to do that. I need some help
Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
child: Column(
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.blue,
padding:
EdgeInsets.symmetric(horizontal: 30, vertical: 15),
),
onPressed: (() {}),
child: Text(
'Projects',
style: TextStyle(
fontSize: 20.0,
),
),
),
SizedBox(
height: 50.0,
),
],
),
),
),
I tried to use Padding, but I’m new to Flutter
4
Answers
Try using Align widget like
Wrap the ElevatedButton in Row and add Expanded(child: SizedBox.expand()) as first child to this row and ElevatedButton as 2nd child.
You can give
crossAxisAlignment
to your column:If this doesn’t work, you can also do this:
It depends on the widget tree, how its aligned. Your
Padding
widget may be wrapped inside some widget which is center aligned. So assuming that yourPadding
widget alignment is not affected by any parent widget. Here is solution to this.There are multiple approaches for that. For example,
crossAxisAlignment: CrossAxisAlignment.end,
inColumn
attributes.ElevatedButton
inside aRow
and add themainAxisAlignment: MainAxisAlignment.end,
attributes.Align
class to make it work.Just like this, here i have used both
Column
andRow
alignments for the sake of demonstration. But you can use whatever suits best to your situation.