CardButton constructor

const CardButton({
  1. Key? key,
  2. required Widget child,
  3. VoidCallback? onPressed,
  4. bool? enabled,
  5. Widget? leading,
  6. Widget? trailing,
  7. AlignmentGeometry? alignment,
  8. ButtonSize size = ButtonSize.normal,
  9. ButtonDensity density = ButtonDensity.normal,
  10. ButtonShape shape = ButtonShape.rectangle,
  11. FocusNode? focusNode,
  12. bool disableTransition = false,
  13. ValueChanged<bool>? onHover,
  14. ValueChanged<bool>? onFocus,
  15. bool? enableFeedback,
  16. GestureTapDownCallback? onTapDown,
  17. GestureTapUpCallback? onTapUp,
  18. GestureTapCancelCallback? onTapCancel,
  19. GestureTapDownCallback? onSecondaryTapDown,
  20. GestureTapUpCallback? onSecondaryTapUp,
  21. GestureTapCancelCallback? onSecondaryTapCancel,
  22. GestureTapDownCallback? onTertiaryTapDown,
  23. GestureTapUpCallback? onTertiaryTapUp,
  24. GestureTapCancelCallback? onTertiaryTapCancel,
  25. GestureLongPressStartCallback? onLongPressStart,
  26. GestureLongPressUpCallback? onLongPressUp,
  27. GestureLongPressMoveUpdateCallback? onLongPressMoveUpdate,
  28. GestureLongPressEndCallback? onLongPressEnd,
  29. GestureLongPressUpCallback? onSecondaryLongPress,
  30. GestureLongPressUpCallback? onTertiaryLongPress,
})

Creates a CardButton with card-styled appearance and comprehensive interaction support.

The child parameter is required and provides the button's main content. The button uses card styling with elevated appearance for visual prominence. Extensive gesture support enables complex interactions beyond simple taps.

Parameters include standard button properties (onPressed, enabled, leading, trailing) along with size, density, and shape customization options. Gesture callbacks support primary, secondary, tertiary taps and long presses.

Parameters:

  • child (Widget, required): The main content displayed in the button
  • onPressed (VoidCallback?, optional): Primary action when button is pressed
  • enabled (bool?, optional): Whether button accepts input (null uses onPressed)
  • size (ButtonSize, default: normal): Size variant for button dimensions
  • density (ButtonDensity, default: normal): Spacing density setting
  • shape (ButtonShape, default: rectangle): Border radius and corner styling

Example:

CardButton(
  size: ButtonSize.large,
  leading: Icon(Icons.star),
  onPressed: () => _handleFavorite(),
  child: Text('Add to Favorites'),
)

Implementation

const CardButton({
  super.key,
  required this.child,
  this.onPressed,
  this.enabled,
  this.leading,
  this.trailing,
  this.alignment,
  this.size = ButtonSize.normal,
  this.density = ButtonDensity.normal,
  this.shape = ButtonShape.rectangle,
  this.focusNode,
  this.disableTransition = false,
  this.onHover,
  this.onFocus,
  this.enableFeedback,
  this.onTapDown,
  this.onTapUp,
  this.onTapCancel,
  this.onSecondaryTapDown,
  this.onSecondaryTapUp,
  this.onSecondaryTapCancel,
  this.onTertiaryTapDown,
  this.onTertiaryTapUp,
  this.onTertiaryTapCancel,
  this.onLongPressStart,
  this.onLongPressUp,
  this.onLongPressMoveUpdate,
  this.onLongPressEnd,
  this.onSecondaryLongPress,
  this.onTertiaryLongPress,
});