cupertinoButton method
CupertinoButton
cupertinoButton({
- CupertinoButtonSize sizeStyle = CupertinoButtonSize.large,
- EdgeInsetsGeometry? padding,
- Color? color,
- Color disabledColor = CupertinoColors.quaternarySystemFill,
- @Deprecated('Use minimumSize instead') double? minSize,
- Size? minimumSize,
- double? pressedOpacity = 0.4,
- BorderRadius? borderRadius,
- AlignmentGeometry alignment = Alignment.center,
- Color? focusColor,
- FocusNode? focusNode,
- void onFocusChange()?,
- bool autofocus = false,
- void onLongPress()?,
- required void onPressed()?,
Creates a standard CupertinoButton with this widget as its child.
A CupertinoButton is an iOS-style button that follows Apple's Human Interface Guidelines. It provides haptic feedback and smooth animations when pressed.
The button can be customized with various parameters including size, color, padding, and interaction behaviors.
Parameters:
sizeStyle
- The size style of the button (small, medium, large). Defaults to large.padding
- Internal padding around the child widget. If null, uses default padding based on size style.color
- Background color of the button. If null, the button is transparent.disabledColor
- Background color when the button is disabled. Defaults to quaternary system fill.minSize
- Deprecated: UseminimumSize
instead. Minimum size for the button.minimumSize
- Minimum size constraint for the button. Takes precedence overminSize
.pressedOpacity
- Opacity level when the button is pressed. Defaults to 0.4.borderRadius
- Corner radius of the button. If null, uses default radius.alignment
- How to align the child within the button. Defaults to center.focusColor
- Color overlay when the button has focus (for accessibility).focusNode
- Focus node for keyboard navigation and accessibility.onFocusChange
- Callback when focus state changes.autofocus
- Whether this button should automatically receive focus. Defaults to false.onLongPress
- Callback for long press gestures. If null, long press is disabled.onPressed
- Required callback for tap gestures. If null, button is disabled.
Returns a CupertinoButton with this widget as its child.
Example:
Icon(CupertinoIcons.heart).cupertinoButton(
color: CupertinoColors.systemRed,
onPressed: () => toggleFavorite(),
onLongPress: () => showFavoriteOptions(),
);
Implementation
CupertinoButton cupertinoButton({
CupertinoButtonSize sizeStyle = CupertinoButtonSize.large,
EdgeInsetsGeometry? padding,
Color? color,
Color disabledColor = CupertinoColors.quaternarySystemFill,
@Deprecated('Use minimumSize instead') double? minSize,
Size? minimumSize,
double? pressedOpacity = 0.4,
BorderRadius? borderRadius,
AlignmentGeometry alignment = Alignment.center,
Color? focusColor,
FocusNode? focusNode,
void Function(bool)? onFocusChange,
bool autofocus = false,
void Function()? onLongPress,
required void Function()? onPressed,
}) =>
CupertinoButton(
sizeStyle: sizeStyle,
padding: padding,
color: color,
disabledColor: disabledColor,
minimumSize:
minimumSize ?? (minSize != null ? Size(minSize, minSize) : null),
pressedOpacity: pressedOpacity,
borderRadius: borderRadius,
alignment: alignment,
focusColor: focusColor,
focusNode: focusNode,
onFocusChange: onFocusChange,
autofocus: autofocus,
onLongPress: onLongPress,
onPressed: onPressed,
child: this,
);