Flutter:如何使ClipOval孩子居中

时间:2019-10-24 11:36:00

标签: flutter flutter-layout

我正在尝试设置IconButton的背景颜色

这是我的代码

ClipOval(
                    child: Container(
                      height: 50.0,
                      width: 50.0,
                      color: Colors.white,
                      child: IconButton(
                        color: Colors.green.withOpacity(0.8),
                        iconSize: 50.0,
                        icon: Icon(Icons.add_circle),

这是结果

enter image description here

如何使椭圆形ContainerIconButton的大小相同并且全部居中?

1 个答案:

答案 0 :(得分:1)

您不需要使用Container的{​​{1}}和width属性,因为您已经在height中使用了iconSize。删除IconButton中的iconSizewidth/height

屏幕截图:

enter image description here

Container