Button class
/////////////////////////////////////////////////////////////////////////////////////////////////
Transforms any widget in a button, with visual feedback in the onPointerDown.
The widget must be created with a builder of type ButtonBuilder, which provides an
isPressed
boolean to indicate whether the button is pressed or not.
Thus, the widget can change its look according to these values.
There are 3 possibilities to detect gestures:
-
Use the onTap parameter.
-
The widget itself can contain a GestureDetector.
-
The Button can be inside a parent that detects gestures. Even with a null onTap, the look still changes when you touch the button. This allows the button to be used inside other widgets that detect gestures. Note that
isPressed
is changed immediately as soon as the user touches the button, through a listener, which is faster than GestureDetector (which has a delay to differentiate between the various types of gestures).
- Inheritance
Constructors
- Button({Key? key, required ButtonBuilder builder, required VoidCallback? onTap, bool? disable, VoidCallback? onDragUp, bool delay = false, Duration? minVisualTapDuration, Duration? tapThrottle, EdgeInsetsGeometry? clickAreaMargin, bool debugShowClickableArea = false})
-
const
Properties
- builder → ButtonBuilder
-
final
- clickAreaMargin → EdgeInsetsGeometry?
-
final
- colorOfClickableArea → Color
-
final
- delay → bool
-
You should pass delay=true only when the widget is inside a scrollable. This makes the button
color change wait a few milliseconds (for when the user actually wants to start a scroll and
not press the button).
final
- disable → bool
-
If disable is true, the onTap and onDragUp won't work.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- minVisualTapDuration → Duration?
-
The minimum duration you want the button to show it was tapped.
final
- onDragUp → VoidCallback?
-
final
- onTap → VoidCallback?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tapThrottle → Duration?
-
The button does not allow calling onTap more than once per tapThrottle. Note: Visually it
may appear to respond, but onTap is not called. Note: If tapThrottle doesn't seem to be
working, check that you're not accidentally calling initState. Obviously, initState resets
the time count.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _ButtonState -
Creates the mutable state for this widget at a given location in the tree.
override
-
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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 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}) → 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
Constants
- delayMillis → const int