The framework for building material design buttons.

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

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

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

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

See also:

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

Constructors

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. [...]
const

Properties

child Widget
The widget below this widget in the tree.
final
color Color
The primary color of the button, as printed on the Material, while it is in its default (unpressed, enabled) state. [...]
final
colorBrightness Brightness
The theme brightness to use for this button. [...]
final
elevation double
The z-coordinate at which to place this button. This controls the size of the shadow below the button. [...]
final
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.
read-only
height double
The vertical extent of the button. [...]
final
highlightColor Color
The secondary color of the button when the button is in the down (pressed) state. [...]
final
highlightElevation double
The z-coordinate at which to place this button when highlighted. This controls the size of the shadow below the button. [...]
final
minWidth double
The smallest horizontal extent that the button will occupy. [...]
final
onPressed VoidCallback
The callback that is called when the button is tapped or otherwise activated. [...]
final
padding EdgeInsetsGeometry
The amount of space to surround the child inside the bounds of the button. [...]
final
splashColor Color
The primary color of the button when the button is in the down (pressed) state. [...]
final
textColor Color
The color to use for this button's text.
final
textTheme ButtonTextTheme
The color scheme to use for this button's text. [...]
final
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

Methods

createState() → _MaterialButtonState
Creates the mutable state for this widget at a given location in the tree. [...]
debugFillProperties(DiagnosticPropertiesBuilder description) → void
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
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. [...]
inherited
toDiagnosticsNode({String name, DiagnosticsTreeStyle style }) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this object.
inherited
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this node and its descendants. [...]
inherited
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a one-line detailed description of the object. [...]
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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