IconButton中padding的默认值是8.0。因为IconButton遵守Material Design设计规则,需要将边距的最小值设置为48px,所以无法调小padding。
const IconButton({
Key? key,
this.iconSize = 24.0,
this.visualDensity,
this.padding = const EdgeInsets.all(8.0),
this.alignment = Alignment.center,
this.splashRadius,
......
}
调小的解决方案:
方案1、
Container(
padding: const EdgeInsets.all(0.0),
width: 30.0, // you can adjust the width as you need
child: IconButton(
),
),
方案2、
GestureDetector( onTap: () {}, child: Icon(Icons.volume_up) )