首页 > 解决方案 > 如何正确填充具有点击效果的 IconButton?

问题描述

我是新来的。我尝试演示应用程序。我需要 appBar 上的 IconButton 并创建它。但是我将填充设置为 IconButton 并且图标位置发生了变化,但是单击波浪效果没有随 iconButton 改变。

我想正确地将填充设置为 IconButton。

这是我的 appBar :

  appBar: new AppBar(
    title: new Text('Demo App'),
    actions: <Widget>[
      IconButton(
        icon: new Icon(Icons.dehaze, size:45.0, ),
        padding: const EdgeInsets.only(right: 40.0),
        alignment: Alignment.center,
        tooltip: 'Air it',
        onPressed: (){},
    ),
    ],
  ),

标签: flutter

解决方案


在小部件中设置您的图标大小,IconButton而不是Icon. 这样 IconButton 将识别调整大小的图标并为您施展魔法。

 IconButton(
   iconSize: 45,
   icon: new Icon(Icons.dehaze),
   tooltip: 'Air it',
   onPressed: (){},
 ),

推荐阅读