如何使这个箭头图标位于按钮的中心
看到图标的边缘是图标的中心,我想让flutter看到图标的中心是图标的中心
更多解释:
我的代码:
AppBar(
backgroundColor: Colors.transparent,
leading:
// Here the code of the button
SizedBox(
height: getProportionateScreenHeight(20),
width: getProportionateScreenWidth(10),
child: Padding(
padding: EdgeInsets.all(8),
child: FlatButton(
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
color: Colors.white,
onPressed: () {
Navigator.pop(context);
},
child: Center(
child: Icon(
Icons.arrow_back_ios,
),
),
),
),
),
// ....
actions: [
IconButton(
icon: Icon(
Icons.favorite,
color: favFlag ? Colors.red : Colors.red[100],
),
onPressed: () {
setState(() {
favFlag = !favFlag;
});
},
),
],
);
在上次升级之前它一直在与我合作。
appBar: AppBar(
backgroundColor: Colors.transparent,
leading:
// Here the code of the button
SizedBox(
height: 20,
width: 20,
child: Padding(
padding: EdgeInsets.all(8),
child: FlatButton(
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
color: Colors.white,
onPressed: () {
// Navigator.pop(context);
},
child: Center(
child: Icon(
Icons.arrow_back_ios,
),
),
),
),
),
actions: [
IconButton(
icon: Icon(
Icons.favorite,
color: favFlag ? Colors.red : Colors.red[100],
),
onPressed: () {
setState(() {
favFlag = !favFlag;
});
},
),
],
),
我已将其手动定位到中心,所以我更喜欢是否有另一个干净的短解决方案。
AppBar(
backgroundColor: Colors.transparent,
// Here the code of the button
leading: Padding(
padding: EdgeInsets.all(8),
child: FlatButton(
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
color: Colors.white,
onPressed: () {
Navigator.pop(context);
},
child: Stack(
alignment: Alignment.center,
children: [
Positioned.directional(
textDirection: Directionality.of(context),
end: 3,
child: Icon(
Icons.arrow_back_ios,
),
),
],
),
),
),
// ....
actions: [
IconButton(
icon: Icon(
Icons.favorite,
color: favFlag ? Colors.red : Colors.red[100],
),
onPressed: () {
setState(() {
favFlag = !favFlag;
});
AdsService.listByPagination();
},
),
],
);
使用Icons.arrow_back_ios,
应该有效