如何在Flutter中调整IconButton的大小(高度和宽度)?看起来它需要默认的宽度和高度.没有高度或宽度属性.
new IconButton(
padding: new EdgeInsets.all(0.0),
color: themeData.primaryColor,
icon: new Icon(Icons.clear, size: 18.0),
onPressed: onDelete,
)
Run Code Online (Sandbox Code Playgroud)
Ste*_*ane 25
您可以使用SizedBox强制它自行调整大小.
new SizedBox(
height: 18.0,
width: 18.0,
child: new IconButton(
padding: new EdgeInsets.all(0.0),
color: themeData.primaryColor,
icon: new Icon(Icons.clear, size: 18.0),
onPressed: onDelete,
)
)
Run Code Online (Sandbox Code Playgroud)
adr*_*ntu 25
有一种比接受的答案更新的方法。它看起来像这样:
IconButton(
iconSize: 18.0,
icon: new Icon(Icons.clear)
Run Code Online (Sandbox Code Playgroud)
所以使用 iconSize 属性并摆脱 SizedBox。
我注意到按下按钮时,旧的已接受解决方案的绘图效果不佳。
dfm*_*ler 18
您可以用 InkWell 替换 IconButton:
InkWell(
child: Icon(Icons.clear, size: 18.0, color: themeData.primaryColor),
onTap: onDelete,
),
Run Code Online (Sandbox Code Playgroud)
小智 11
如果有人想要更改图标按钮的启动/悬停阴影大小。您需要将 IconButton 中的splashRadius 属性设置为所需的值。
IconButton(
splashRadius: 12,
padding: EdgeInsets.zero,
icon: Icon(
Icons.visibility,
color: Theme.of(context).primaryColorDark,
),
)
Run Code Online (Sandbox Code Playgroud)
使用该constraints
属性IconButton
:
IconButton(
constraints: BoxConstraints(maxHeight: 36),
icon: new Icon(Icons.clear, size: 18.0),
)
Run Code Online (Sandbox Code Playgroud)
使用IconButton > splashRadius
,
IconButton(
// use this to decrease/increase the splash spacing
splashRadius: 24.0, // (Material.defaultSplashRadius = 35.0)
color: buttonColor,
icon: Icon(Icons.heart),
onPressed: () {},
);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9737 次 |
最近记录: |