MaterialButton class

A utility class for building Material buttons that depend on the ambient ButtonTheme and Theme.

The button's size will expand to fit the child widget, if necessary.

MaterialButtons whose onPressed handler is null will be disabled. To have an enabled button, make sure to pass a non-null value for onPressed.

Rather than using this class directly, consider using FlatButton or RaisedButton, which configure this class with appropriate defaults that match the material design specification.

To create a button directly, without inheriting theme defaults, use RawMaterialButton.

If you want an ink-splash effect for taps, but don't want to use a button, consider using InkWell directly.

See also:

  • IconButton, to create buttons that contain icons rather than text.


MaterialButton({Key key, Brightness colorBrightness, ButtonTextTheme textTheme, Color textColor, Color color, Color highlightColor, Color splashColor, double elevation, double highlightElevation, double minWidth, double height, EdgeInsetsGeometry padding, @required VoidCallback onPressed, Widget child })
Creates a material button. [...]


child Widget
The widget below this widget in the tree. [...]
color Color
The button's fill color, displayed by its Material, while the button is in its default (unpressed, enabled) state. [...]
colorBrightness Brightness
The theme brightness to use for this button. [...]
elevation double
The z-coordinate at which to place this button. This controls the size of the shadow below the button. [...]
enabled bool
Whether the button is enabled or disabled. Buttons are disabled by default. To enable a button, set its onPressed property to a non-null value.
height double
The vertical extent of the button. [...]
highlightColor Color
The secondary color of the button when the button is in the down (pressed) state. [...]
highlightElevation double
The z-coordinate at which to place this button when highlighted. This controls the size of the shadow below the button. [...]
minWidth double
The smallest horizontal extent that the button will occupy. [...]
onPressed VoidCallback
The callback that is called when the button is tapped or otherwise activated. [...]
padding EdgeInsetsGeometry
The internal padding for the button's child. [...]
splashColor Color
The primary color of the button when the button is in the down (pressed) state. [...]
textColor Color
The color to use for this button's text.
textTheme ButtonTextTheme
Defines the button's base colors, and the defaults for the button's minimum size, internal padding, and shape.
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
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 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. [...]