Reputation: 12304
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?
Upvotes: 8
Views: 7147
Reputation: 1141
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: () {},
),
],
);
Upvotes: 27