How to resize (height and width) of an IconButton in Flutter? Seems like it takes a default width and height. There is not height or width property.
new IconButton(
padding: new EdgeInsets.all(0.0),
color: themeData.primaryColor,
icon: new Icon(Icons.clear, size: 18.0),
onPressed: onDelete,
)
Raised buttons have a minimum size of 88.0 by 36.0 which can be overridden with ButtonTheme. So you can do it like the following: ButtonTheme( minWidth: 200.0, height: 100.0, child: RaisedButton( onPressed: () {}, child: Text("test"), ), );
The simplest way to create a button with icon and text in Flutter is to use the new Material button called ElevatedButton with an icon constructor. ElevatedButton. icon() gives you the ability to add the icon and label parameter to the button. The ElevatedButton was introduced with the release of Flutter v1.
You can force it to size itself with the 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,
)
)
There is a newer way than the accepted answer. It looks like this:
IconButton(
iconSize: 18.0,
icon: new Icon(Icons.clear)
So use iconSize attribute and get rid of the SizedBox.
I noticed the old accepted solution had a bad drawing effect when pressing the button.
You can replace IconButton with InkWell:
InkWell(
child: Icon(Icons.clear, size: 18.0, color: themeData.primaryColor),
onTap: onDelete,
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With