The icons need to be centred within the Icon buttons otherwise when the two are centred together in the middle of the row, they appear slightly off centre to the right.
Row(
children: <Widget>[
IconButton(
alignment: Alignment.center,
icon: Icon(Icons.arrow_left,
color: Color(0xFFF89CC0), size: 42),
onPressed: () {},
),
IconButton(
alignment: Alignment.topLeft,
icon: Icon(Icons.arrow_right,
color: Color(0xFFF89CC0), size: 42),
onPressed: () {},
},
),
],
),
I have alignment
parameters set which as you can see in the screenshot are completely ignored:
How can I get them to be in the centre of their button?
The problem is that IconButton
s have a default padding, so do it like this:
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.arrow_left, color: Color(0xFFF89CC0), size: 42),
onPressed: () => {},
),
IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.arrow_right, color: Color(0xFFF89CC0), size: 42),
onPressed: () {},
),
],
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With