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.
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 button's fill color, displayed by its Material, while the button 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 internal padding for the button's child. [...]
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
Defines the button's base colors, and the defaults for the button's minimum size, internal padding, and shape.
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

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. [...]
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 ==(dynamic other) bool
The equality operator. [...]
inherited