MaterialButtonData class final
Material-specific configuration for a platform button.
Maps to properties of Material button widgets (e.g., ElevatedButton,
TextButton, OutlinedButton) on Android. Use this class to configure
platform-specific styling and behavior for Material buttons.
Example:
MaterialButtonData(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
),
onHover: (isHovered) => print('Hovered: $isHovered'),
)
Constructors
-
MaterialButtonData({bool isEnabled = true, VoidCallback? onPressed, VoidCallback? onLongPress, MouseCursor? mouseCursor, FocusNode? focusNode, bool autofocus = kDefaultAutofocus, Widget? child, Key? widgetKey, ValueChanged<
bool> ? onHover, ValueChanged<bool> ? onFocusChange, ButtonStyle? style, Clip? clipBehavior, WidgetStatesController? statesController, bool? isSemanticButton, Widget? icon, Widget? label, IconAlignment? iconAlignment}) -
childand (icon,label) are mutually exclusive. They are used to indicate the calling for the different variant of the button.childis used for the normal button-constructors (useNormalConstructor). (icon,label) are used for the.icon-constructors (useNormalConstructor).
When useNormalConstructor istrue,iconAlignmentwill be ignored. When useIconConstructor istrue,mouseCursorwill be ignored.isSemanticButtonseems to be only available forTextButton.const
Properties
- autofocus → bool
-
Whether the button should automatically focus when it's first displayed.
finalinherited
- child → Widget?
-
The widget to display as the button's label.
finalinherited
- clipBehavior → Clip?
-
Clip behavior for the button.
final
- focusNode → FocusNode?
-
The focus node for the button.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → Widget?
-
Icon widget for the
.iconconstructor variant.final - iconAlignment → IconAlignment?
-
Alignment of the icon relative to the label.
final
- isEnabled → bool
-
Whether the button is enabled and can be pressed.
finalinherited
- isSemanticButton → bool?
-
Whether the button is a semantic button for accessibility.
final
- label → Widget?
-
Label widget for the
.iconconstructor variant.final - mouseCursor → MouseCursor?
-
The cursor to display when the mouse hovers over the button.
finalinherited
-
onFocusChange
→ ValueChanged<
bool> ? -
Callback when the focus state changes.
final
-
onHover
→ ValueChanged<
bool> ? -
Callback when the hover state changes.
final
- onLongPress → VoidCallback?
-
Callback that is called when the button is long-pressed.
finalinherited
- onPressed → VoidCallback?
-
Callback that is called when the button is pressed.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statesController → WidgetStatesController?
-
Controller for the widget states.
final
- style → ButtonStyle?
-
The button style to apply.
final
- useIconConstructor → bool
-
Whether the icon constructor should be used.
no setter
- useNormalConstructor → bool
-
Whether the normal (child-based) constructor should be used.
no setter
- widgetKey → Key?
-
Optional key for the button widget.
finalinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited