IconButton class

A material design icon button.

An icon button is a picture printed on a Material widget that reacts to touches by filling with color (ink).

Icon buttons are commonly used in the AppBar.actions field, but they can be used in many other places as well.

If the onPressed callback is null, then the button will be disabled and will not react to touch.

Requires one of its ancestors to be a Material widget.

The hit region of an icon button will, if possible, be at least kMinInteractiveDimension pixels in size, regardless of the actual iconSize, to satisfy the touch target size requirements in the Material Design specification. The alignment controls how the icon itself is positioned within the hit region.

This sample shows an IconButton that uses the Material icon "volume_up" to increase the volume.
double _volume = 0.0;

// ...

Widget build(BuildContext context) {
  return Scaffold(
    body: Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
            icon: Icon(Icons.volume_up),
            tooltip: 'Increase volume by 10',
            onPressed: () {
              setState(() {
                _volume += 10;
          Text('Volume : $_volume')

Adding a filled background

Icon buttons don't support specifying a background color or other background decoration because typically the icon is just displayed on top of the parent widget's background. Icon buttons that appear in AppBar.actions are an example of this.

It's easy enough to create an icon button with a filled background using the Ink widget. The Ink widget renders a decoration on the underlying Material along with the splash and highlight InkResponse contributed by descendant widgets.

In this sample the icon button's background color is defined with an Ink widget whose child is an IconButton. The icon button's filled background is a light shade of blue, it's a filled circle, and it's as big as the button is.
Widget build(BuildContext context) {
  return Center(
    child: Container(
      child: Ink(
        decoration: ShapeDecoration(
          color: Colors.lightBlue,
          shape: CircleBorder(),
        child: IconButton(
          icon: Icon(Icons.android),
          color: Colors.white,
          onPressed: () {
            print("filled background");

See also:



IconButton({Key key, double iconSize: 24.0, EdgeInsetsGeometry padding: const EdgeInsets.all(8.0), AlignmentGeometry alignment: Alignment.center, @required Widget icon, Color color, Color focusColor, Color hoverColor, Color highlightColor, Color splashColor, Color disabledColor, @required VoidCallback onPressed, FocusNode focusNode, bool autofocus: false, String tooltip })
Creates an icon button. [...]


alignment AlignmentGeometry
Defines how the icon is positioned within the IconButton. [...]
autofocus bool
True if this widget will be selected as the initial focus when no other node in its scope is currently focused. [...]
color Color
The color to use for the icon inside the button, if the icon is enabled. Defaults to leaving this up to the icon widget. [...]
disabledColor Color
The color to use for the icon inside the button, if the icon is disabled. Defaults to the ThemeData.disabledColor of the current Theme. [...]
focusColor Color
The color for the button's icon when it has the input focus. [...]
focusNode FocusNode
An optional focus node to use as the focus node for this widget. [...]
highlightColor Color
The secondary color of the button when the button is in the down (pressed) state. The highlight color is represented as a solid color that is overlaid over the button color (if any). If the highlight color has transparency, the button color will show through. The highlight fades in quickly as the button is held down. [...]
hoverColor Color
The color for the button's icon when a pointer is hovering over it. [...]
icon Widget
The icon to display inside the button. [...]
iconSize double
The size of the icon inside the button. [...]
onPressed VoidCallback
The callback that is called when the button is tapped or otherwise activated. [...]
padding EdgeInsetsGeometry
The padding around the button's icon. The entire padded icon will react to input gestures. [...]
splashColor Color
The primary color of the button when the button is in the down (pressed) state. The splash is represented as a circular overlay that appears above the highlightColor overlay. The splash overlay has a center point that matches the hit point of the user touch event. The splash overlay will expand to fill the button area if the touch is held for long enough time. If the splash color has transparency then the highlight and button color will show through. [...]
tooltip String
Text that describes the action that will occur when the button is pressed. [...]
hashCode int
The hash code for this object. [...]
read-only, inherited
key Key
Controls how one widget replaces another widget in the tree. [...]
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree. [...]
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDiagnosticsNode({String name, DiagnosticsTreeStyle style }) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
toString({DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this object.
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this node and its descendants. [...]
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a one-line detailed description of the object. [...]
toStringShort() String
A short, textual description of this widget.


operator ==(dynamic other) bool
The equality operator. [...]