图标必须在“图标”按钮中居中,否则当两个图标在行中间居中放置时,它们会稍微偏离右侧中心。
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: () {},
},
),
],
),
我设置了alignment
个参数,正如您在屏幕快照中看到的那样,这些参数被完全忽略:
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint
如何使它们位于按钮的中央?
答案 0 :(得分:1)
问题是IconButton
具有默认填充,因此请执行以下操作:
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: () {},
),
],
);