AsyncCupertinoButton class

A native CupertinoButton with external and async loading states.

Effective loading is loading or a pending onPressed or onError. Loading disables outer activation; built-in transitions exclude inactive content from pointer input, focus, and semantics. Unhandled errors propagate with their original stack trace. Return or await all work to be tracked. Disposal does not cancel that work or its captured error handler.

Works under CupertinoApp without a Material ancestor. Native sizes, padding, colors, focus, and press feedback are preserved. Larger loadingChild content can affect layout within native and parent constraints. customBuilder owns sizing and all content interaction, focus, and semantics.

Inheritance

Constructors

AsyncCupertinoButton({required Widget child, required FutureOr<void> onPressed()?, AsyncButtonErrorHandler? onError, bool loading = false, Widget? loadingChild, String? loadingSemanticsLabel, CupertinoButtonSize sizeStyle = CupertinoButtonSize.large, EdgeInsetsGeometry? padding, Color? color, Color? foregroundColor, Color disabledColor = CupertinoColors.quaternarySystemFill, Size? minimumSize, double? pressedOpacity = 0.4, BorderRadius? borderRadius, AlignmentGeometry alignment = Alignment.center, Color? focusColor, FocusNode? focusNode, ValueChanged<bool>? onFocusChange, bool autofocus = false, MouseCursor? mouseCursor, VoidCallback? onLongPress, Duration animationDuration = const Duration(milliseconds: 200), double minimumChildOpacity = 0.0, TransitionAnimationType transitionType = TransitionAnimationType.stack, Widget customBuilder(bool loading, Widget child, Widget? loadingChild)?, Key? key})
Creates an iOS-style button with tracked async activation.
const
AsyncCupertinoButton.filled({required Widget child, required FutureOr<void> onPressed()?, AsyncButtonErrorHandler? onError, bool loading = false, Widget? loadingChild, String? loadingSemanticsLabel, CupertinoButtonSize sizeStyle = CupertinoButtonSize.large, EdgeInsetsGeometry? padding, Color? color, Color? foregroundColor, Color disabledColor = CupertinoColors.tertiarySystemFill, Size? minimumSize, double? pressedOpacity = 0.4, BorderRadius? borderRadius, AlignmentGeometry alignment = Alignment.center, Color? focusColor, FocusNode? focusNode, ValueChanged<bool>? onFocusChange, bool autofocus = false, MouseCursor? mouseCursor, VoidCallback? onLongPress, Duration animationDuration = const Duration(milliseconds: 200), double minimumChildOpacity = 0.0, TransitionAnimationType transitionType = TransitionAnimationType.stack, Widget customBuilder(bool loading, Widget child, Widget? loadingChild)?, Key? key})
Creates an iOS-style button with a filled background with tracked async activation.
const
AsyncCupertinoButton.tinted({required Widget child, required FutureOr<void> onPressed()?, AsyncButtonErrorHandler? onError, bool loading = false, Widget? loadingChild, String? loadingSemanticsLabel, CupertinoButtonSize sizeStyle = CupertinoButtonSize.large, EdgeInsetsGeometry? padding, Color? color, Color? foregroundColor, Color disabledColor = CupertinoColors.tertiarySystemFill, Size? minimumSize, double? pressedOpacity = 0.4, BorderRadius? borderRadius, AlignmentGeometry alignment = Alignment.center, Color? focusColor, FocusNode? focusNode, ValueChanged<bool>? onFocusChange, bool autofocus = false, MouseCursor? mouseCursor, VoidCallback? onLongPress, Duration animationDuration = const Duration(milliseconds: 200), double minimumChildOpacity = 0.0, TransitionAnimationType transitionType = TransitionAnimationType.stack, Widget customBuilder(bool loading, Widget child, Widget? loadingChild)?, Key? key})
Creates an iOS-style button with a tinted background with tracked async activation.
const

Properties

alignment → AlignmentGeometry
The native content alignment, defaulting to Alignment.center.
final
animationDuration → Duration
The loading transition duration, defaulting to 200 milliseconds.
final
autofocus → bool
Whether the native button requests initial focus.
final
borderRadius → BorderRadius?
The native corner radius when the button has a background.
final
child → Widget
The idle button content.
final
color → Color?
The native background color, with theme-derived filled and tinted defaults.
final
customBuilder → Widget Function(bool loading, Widget child, Widget? loadingChild)?
Required presentation builder for TransitionAnimationType.customBuilder.
final
disabledColor → Color
The native disabled background color, with variant-specific defaults.
final
focusColor → Color?
The native keyboard focus highlight color.
final
focusNode → FocusNode?
The native focus node.
final
foregroundColor → Color?
The native foreground color, also used by the default loading indicator.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loading → bool
Whether the application requests loading, independently of pending work.
final
loadingChild → Widget?
Optional loading content, replacing the default CupertinoActivityIndicator.
final
loadingSemanticsLabel → String?
The optional localized accessible label for the default indicator.
final
minimumChildOpacity → double
The idle content opacity during stack loading, defaulting to 0.0.
final
minimumSize → Size?
The native minimum button size.
final
mouseCursor → MouseCursor?
The native mouse cursor, including state-dependent cursors.
final
onError → AsyncButtonErrorHandler?
The optional handler that explicitly consumes activation errors.
final
onFocusChange → ValueChanged<bool>?
Called when native focus changes.
final
onLongPress → VoidCallback?
The synchronous long-press callback, blocked while loading.
final
onPressed → FutureOr<void> Function()?
The synchronous or asynchronous activation callback.
final
padding → EdgeInsetsGeometry?
The native padding around the content, resolved by CupertinoButton.
final
pressedOpacity → double?
The opacity while pressed, defaulting to 0.4; null disables press fading.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sizeStyle → CupertinoButtonSize
The native button size, defaulting to CupertinoButtonSize.large.
final
transitionType → TransitionAnimationType
The loading transition, defaulting to TransitionAnimationType.stack.
final

Methods

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