Button class

Inheritance
Available extensions

Constructors

Button.new({Key? key, required VoidCallback? onPressed, VoidCallback? onLongPress, ValueChanged<bool>? onHover, ValueChanged<bool>? onFocusChange, ButtonStyle? style, FocusNode? focusNode, bool autofocus = false, Clip? clipBehavior = Clip.none, MaterialStatesController? statesController, ButtonType? type, bool square = false, double? radius = 15, Size? fixedSize, BorderSide? side, TextStyle? textStyle, Color? backgroundColor, Color? foregroundColor, Color? overlayColor, Color? shadowColor, Color? surfaceTintColor, double? elevation, EdgeInsetsGeometry? padding, Size? minimumSize, Size? maximumSize, OutlinedBorder? shape, MouseCursor? mouseCursor, VisualDensity? visualDensity, MaterialTapTargetSize? tapTargetSize, Duration? animationDuration, bool? enableFeedback, AlignmentGeometry? alignment, InteractiveInkFeatureFactory? splashFactory, required Widget? child})

Properties

alignment AlignmentGeometry?
getter/setter pair
animationDuration Duration?
getter/setter pair
autofocus bool
True if this widget will be selected as the initial focus when no other node in its scope is currently focused.
finalinherited
backgroundColor Color?
getter/setter pair
child Widget?
Typically the button's label.
finalinherited
clipBehavior Clip?
The content will be clipped (or not) according to this option.
finalinherited
disabledBackgroundColor Color?
getter/setter pair
disabledForegroundColor Color?
getter/setter pair
elevation double?
getter/setter pair
enabled bool
Whether the button is enabled or disabled.
no setterinherited
enableFeedback bool?
getter/setter pair
fixedSize Size?
getter/setter pair
focusNode FocusNode?
An optional focus node to use as the focus node for this widget.
finalinherited
foregroundColor Color?
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hoverBackgroundColor Color?
getter/setter pair
hoverForegroundColor Color?
getter/setter pair
iconAlignment IconAlignment?
Determines the alignment of the icon within the widgets such as:
finalinherited
isSemanticButton bool?
Determine whether this subtree represents a button.
finalinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
marginZero Widget

Available on Widget, provided by the WidgetMarginX extension

no setter
maximumSize Size?
getter/setter pair
minimumSize Size?
getter/setter pair
mouseCursor MouseCursor?
getter/setter pair
onFocusChange ValueChanged<bool>?
Handler called when the focus changes.
finalinherited
onHover ValueChanged<bool>?
Called when a pointer enters or exits the button response area.
finalinherited
onLongPress VoidCallback?
Called when the button is long-pressed.
finalinherited
onPressed VoidCallback?
Called when the button is tapped or otherwise activated.
finalinherited
overlayColor Color?
getter/setter pair
padding EdgeInsetsGeometry?
getter/setter pair
paddingZero Widget

Available on Widget, provided by the WidgetPaddingX extension

no setter
radius double?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shadowColor Color?
getter/setter pair
shape OutlinedBorder?
getter/setter pair
side BorderSide?
getter/setter pair
sliverBox Widget

Available on Widget, provided by the WidgetSliverBoxX extension

no setter
splashFactory InteractiveInkFeatureFactory?
getter/setter pair
square bool
getter/setter pair
statesController MaterialStatesController?
Represents the interactive "state" of this widget in terms of a set of WidgetStates, like WidgetState.pressed and WidgetState.focused.
finalinherited
style ButtonStyle?
Customizes this button's appearance.
finalinherited
surfaceTintColor Color?
getter/setter pair
tapTargetSize MaterialTapTargetSize?
getter/setter pair
textStyle TextStyle?
getter/setter pair
tooltip String?
Text that describes the action that will occur when the button is pressed or hovered over.
finalinherited
type ButtonType?
final
visualDensity VisualDensity?
getter/setter pair

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<ButtonStyleButton>
Creates the mutable state for this widget at a given location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
defaultStyleOf(BuildContext context) ButtonStyle
Defines the button's default appearance.
override
marginAll(double margin) Widget

Available on Widget, provided by the WidgetMarginX extension

marginOnly({double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) Widget

Available on Widget, provided by the WidgetMarginX extension

marginSymmetric({double horizontal = 0.0, double vertical = 0.0}) Widget

Available on Widget, provided by the WidgetMarginX extension

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
paddingAll(double padding) Widget

Available on Widget, provided by the WidgetPaddingX extension

paddingOnly({double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) Widget

Available on Widget, provided by the WidgetPaddingX extension

paddingSymmetric({double horizontal = 0.0, double vertical = 0.0}) Widget

Available on Widget, provided by the WidgetPaddingX extension

themeStyleOf(BuildContext context) ButtonStyle?
Returns the ElevatedButtonThemeData.style of the closest ElevatedButtonTheme ancestor.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) 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 ==(Object other) bool
The equality operator.
inherited