ActionButton class

A wrapper of Material buttons, that manages a state of an action which is performed on the button click, and updates the button content to display the progress state of the action.

The buttonType property defines the underlying Material button widget - TextButton, ElevatedButton or OutlinedButton. The ActionButton supports all attributes of those button widgets.

A function provided in the action attribute, is called when user click the button. This function must return Future. During performing the action, the progressView is displayed as a button child. When it is not specified, the ProgressUic widget is shown.

ActionButton provides callbacks for action states:

  • onActionStarted is called immediately after clicking the button, before the action is started,
  • onActionCompleted is called when the action is successfully completed,
  • onActionError is called if the action finished with error.

See also:

Inheritance

Constructors

ActionButton({Key? key, required Future<void> action(), bool autofocus = false, ActionButtonType buttonType = ActionButtonType.text, required Widget child, Clip clipBehavior = Clip.none, FocusNode? focusNode, VoidCallback? onActionCompleted, void onActionError(Object? error)?, VoidCallback? onActionStarted, Widget? progressView, ButtonStyle? style})
const

Properties

action Future<void> Function()
An action, that is performed on button pressed.
final
autofocus bool
final
buttonType ActionButtonType
Defines the underlying Material button widget.
final
child Widget
final
clipBehavior Clip
final
focusNode FocusNode?
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onActionCompleted VoidCallback?
A callback that is called when the action is successfully completed.
final
onActionError → void Function(Object? error)?
A callback that is called when the action is finished with error.
final
onActionStarted VoidCallback?
A callback that is called immediately after the button is pressed, before starting the action.
final
progressView Widget?
A custom view, that is displayed as a button child when the action is in progress.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
style ButtonStyle?
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _ActionButtonState
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