AsyncCommonButton class

A CommonButton wrapper that drives itself through AsyncButtonStatus.loading/success/error around an async onPressed callback — the state machine BackupRestorePanel and similar hand-rolled per-widget before this existed (FEAT-50). Ignores a tap while not AsyncButtonStatus.idle (a rapid double-tap can't start a second onPressed call, and a tap during the success/error cooldown is ignored too, not queued).

onPressed left null disables the button (mirrors CommonButton's own onTap: null convention) — for a business-rule gate (e.g. "select at least one option first"), not for hiding that async work is in flight (that's what AsyncButtonStatus.loading is for).

Inheritance

Constructors

AsyncCommonButton({Key? key, String? label, IconData? icon, CommonButtonVariant variant = CommonButtonVariant.primary, required Future<void> onPressed()?, Color? color, double? width, String? semanticLabel, Duration? timeout, IconData successIcon = Icons.check_circle, IconData errorIcon = Icons.error, Duration successDuration = const Duration(seconds: 1), Duration errorDuration = const Duration(seconds: 2), String loadingAnnouncement = 'Loading', String? successAnnouncement, String errorAnnouncement = 'Action failed'})
const

Properties

color → Color?
final
errorAnnouncement → String
final
errorDuration → Duration
final
errorIcon → IconData
final
hashCode → int
The hash code for this object.
no setterinherited
icon → IconData?
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label → String?
final
loadingAnnouncement → String
final
onPressed → Future<void> Function()?
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel → String?
final
successAnnouncement → String?
final
successDuration → Duration
How long AsyncButtonStatus.success/error is shown before the button reverts to idle and becomes tappable again.
final
successIcon → IconData
final
timeout → Duration?
If onPressed hasn't completed within this, it's treated as an error (a TimeoutException is indistinguishable from any other thrown error here — both land in AsyncButtonStatus.error).
final
variant → CommonButtonVariant
final
width → double?
final

Methods

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