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, OutlineButton, 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
- Object
- Diagnosticable
- DiagnosticableTree
- Widget
- StatelessWidget
- MaterialButton
- Implementers
Constructors
-
MaterialButton({Key key, @required VoidCallback onPressed, ValueChanged<
bool> onHighlightChanged, ButtonTextTheme textTheme, Color textColor, Color disabledTextColor, Color color, Color disabledColor, Color highlightColor, Color splashColor, Brightness colorBrightness, double elevation, double highlightElevation, double disabledElevation, EdgeInsetsGeometry padding, ShapeBorder shape, Clip clipBehavior: Clip.none, MaterialTapTargetSize materialTapTargetSize, Duration animationDuration, double minWidth, double height, Widget child }) -
Creates a material button. [...]
const
Properties
- animationDuration → Duration
-
Defines the duration of animated changes for shape and elevation. [...]
final
- child → Widget
-
The button's label. [...]
final
- clipBehavior → Clip
-
The content will be clipped (or not) according to this option. [...]
final
- color → Color
-
The button's fill color, displayed by its Material, while it
is in its default (unpressed, enabled) state. [...]
final
- colorBrightness → Brightness
-
The theme brightness to use for this button. [...]
final
- disabledColor → Color
-
The fill color of the button when the button is disabled. [...]
final
- disabledElevation → double
-
The elevation for the button's Material when the button
is not enabled. [...]
final
- disabledTextColor → Color
-
The color to use for this button's text when the button is disabled. [...]
final
- elevation → double
-
The z-coordinate at which to place this button. This controls the size of
the shadow below the raised button. [...]
final
- enabled → bool
-
Whether the button is enabled or disabled. [...]
read-only
- height → double
-
The vertical extent of the button. [...]
final
- highlightColor → Color
-
The highlight color of the button's InkWell. [...]
final
- highlightElevation → double
-
The elevation for the button's Material when the button
is enabled and pressed. [...]
final
- materialTapTargetSize → MaterialTapTargetSize
-
Configures the minimum size of the tap target. [...]
final
- minWidth → double
-
The smallest horizontal extent that the button will occupy. [...]
final
-
onHighlightChanged
→ ValueChanged<
bool> -
Called by the underlying InkWell widget's InkWell.onHighlightChanged
callback.
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
- shape → ShapeBorder
-
The shape of the button's Material. [...]
final
- splashColor → Color
-
The splash color of the button's InkWell. [...]
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. [...]
override
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node. [...]
override
-
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