AsyncCupertinoButton constructor

const AsyncCupertinoButton({
  1. required Widget child,
  2. required FutureOr<void> onPressed()?,
  3. AsyncButtonErrorHandler? onError,
  4. bool loading = false,
  5. Widget? loadingChild,
  6. String? loadingSemanticsLabel,
  7. CupertinoButtonSize sizeStyle = CupertinoButtonSize.large,
  8. EdgeInsetsGeometry? padding,
  9. Color? color,
  10. Color? foregroundColor,
  11. Color disabledColor = CupertinoColors.quaternarySystemFill,
  12. Size? minimumSize,
  13. double? pressedOpacity = 0.4,
  14. BorderRadius? borderRadius,
  15. AlignmentGeometry alignment = Alignment.center,
  16. Color? focusColor,
  17. FocusNode? focusNode,
  18. ValueChanged<bool>? onFocusChange,
  19. bool autofocus = false,
  20. MouseCursor? mouseCursor,
  21. VoidCallback? onLongPress,
  22. Duration animationDuration = const Duration(milliseconds: 200),
  23. double minimumChildOpacity = 0.0,
  24. TransitionAnimationType transitionType = TransitionAnimationType.stack,
  25. Widget customBuilder(
    1. bool loading,
    2. Widget child,
    3. Widget? loadingChild
    )?,
  26. Key? key,
})

Creates an iOS-style button with tracked async activation.

With both onPressed and onLongPress null, the button is disabled.

Implementation

const AsyncCupertinoButton({
  required this.child,
  required this.onPressed,
  this.onError,
  this.loading = false,
  this.loadingChild,
  this.loadingSemanticsLabel,
  this.sizeStyle = CupertinoButtonSize.large,
  this.padding,
  this.color,
  this.foregroundColor,
  this.disabledColor = CupertinoColors.quaternarySystemFill,
  this.minimumSize,
  this.pressedOpacity = 0.4,
  this.borderRadius,
  this.alignment = Alignment.center,
  this.focusColor,
  this.focusNode,
  this.onFocusChange,
  this.autofocus = false,
  this.mouseCursor,
  this.onLongPress,
  this.animationDuration = const Duration(milliseconds: 200),
  this.minimumChildOpacity = 0.0,
  this.transitionType = TransitionAnimationType.stack,
  this.customBuilder,
  super.key,
}) : _variant = _AsyncCupertinoButtonVariant.plain,
     assert(
       pressedOpacity == null ||
           (pressedOpacity >= 0.0 && pressedOpacity <= 1.0),
     ),
     assert(
       transitionType != TransitionAnimationType.customBuilder ||
           customBuilder != null,
       'customBuilder must be provided when transitionType is customBuilder',
     );