RectRevealButton constructor

const RectRevealButton({
  1. Key? key,
  2. required Widget selectedChild,
  3. Widget? unselectedChild,
  4. required VoidCallback onPressed,
  5. Color? selectedBackgroundColor,
  6. Color? unselectedBackgroundColor,
  7. Color? selectedRippleColor,
  8. Color? unselectedRippleColor,
  9. double width = double.infinity,
  10. double height = 48,
  11. double? borderRadius,
  12. Duration? animationDuration,
  13. bool? isSelected,
  14. BoxBorder? border,
  15. EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 16),
  16. AlignmentGeometry alignment = Alignment.center,
  17. RevealDirection revealDirection = RevealDirection.fromClick,
  18. @Deprecated('Use selectedChild instead. Will be removed in v2.0.0') Widget? widgetA,
  19. @Deprecated('Use unselectedChild instead. Will be removed in v2.0.0') Widget? widgetB,
  20. @Deprecated('Use selectedBackgroundColor instead. Will be removed in v2.0.0') Color? backgroundColorA,
  21. @Deprecated('Use unselectedBackgroundColor instead. Will be removed in v2.0.0') Color? backgroundColorB,
  22. @Deprecated('Use selectedRippleColor instead. Will be removed in v2.0.0') Color? rippleColorA,
  23. @Deprecated('Use unselectedRippleColor instead. Will be removed in v2.0.0') Color? rippleColorB,
  24. @Deprecated('Use borderRadius instead. Will be removed in v2.0.0') double? radius,
  25. @Deprecated('Use animationDuration instead. Will be removed in v2.0.0') Duration? duration,
  26. @Deprecated('Use isSelected instead. Will be removed in v2.0.0') bool? selected,
})

Crea un RectRevealButton con efecto de reveal rectangular.

Parámetros requeridos:

  • selectedChild: Widget mostrado cuando el botón está seleccionado.
  • unselectedChild: Widget mostrado cuando el botón NO está seleccionado.
  • onPressed: Callback ejecutado al presionar el botón.

Personalización de colores:

  • selectedBackgroundColor: Color de fondo en estado seleccionado (por defecto: negro).
  • unselectedBackgroundColor: Color de fondo en estado no seleccionado (por defecto: blanco).
  • selectedRippleColor: Color del reveal hacia estado seleccionado (por defecto: blanco).
  • unselectedRippleColor: Color del reveal hacia estado no seleccionado (por defecto: negro).

Dimensiones y apariencia:

  • width: Ancho del botón (por defecto: 120).
  • height: Alto del botón (por defecto: 48).
  • borderRadius: Radio de las esquinas, mínimo 2.0 (por defecto: 2).
  • border: Borde decorativo opcional.
  • padding: Espaciado interno del contenido (por defecto: horizontal 16).
  • alignment: Alineación del contenido (por defecto: centrado).

Control de estado y animación:

  • isSelected: Controla el estado desde el widget padre. Si no se provee, el botón gestiona su propio estado interno.
  • animationDuration: Duración de la animación (por defecto: 300ms).
  • revealDirection: Dirección del efecto reveal (por defecto: desde el click).

Ejemplo:

RectRevealButton(
  selectedChild: const Icon(Icons.check),
  unselectedChild: const Icon(Icons.close),
  revealDirection: RevealDirection.fromLeft,
  onPressed: () => print('Pulsado'),
)

Implementation

const RectRevealButton({
  super.key,
  required Widget selectedChild,
  Widget? unselectedChild,
  required this.onPressed,
  Color? selectedBackgroundColor,
  Color? unselectedBackgroundColor,
  Color? selectedRippleColor,
  Color? unselectedRippleColor,
  this.width = double.infinity,
  this.height = 48,
  double? borderRadius,
  Duration? animationDuration,
  bool? isSelected,
  this.border,
  this.padding = const EdgeInsets.symmetric(horizontal: 16),
  this.alignment = Alignment.center,
  this.revealDirection = RevealDirection.fromClick,
  @Deprecated('Use selectedChild instead. Will be removed in v2.0.0') Widget? widgetA,
  @Deprecated('Use unselectedChild instead. Will be removed in v2.0.0') Widget? widgetB,
  @Deprecated('Use selectedBackgroundColor instead. Will be removed in v2.0.0') Color? backgroundColorA,
  @Deprecated('Use unselectedBackgroundColor instead. Will be removed in v2.0.0') Color? backgroundColorB,
  @Deprecated('Use selectedRippleColor instead. Will be removed in v2.0.0') Color? rippleColorA,
  @Deprecated('Use unselectedRippleColor instead. Will be removed in v2.0.0') Color? rippleColorB,
  @Deprecated('Use borderRadius instead. Will be removed in v2.0.0') double? radius,
  @Deprecated('Use animationDuration instead. Will be removed in v2.0.0') Duration? duration,
  @Deprecated('Use isSelected instead. Will be removed in v2.0.0') bool? selected,
}) : selectedChild = widgetA ?? selectedChild,
     unselectedChild = widgetB ?? unselectedChild,
     selectedBackgroundColor = backgroundColorA ?? selectedBackgroundColor ?? Colors.black,
     unselectedBackgroundColor = backgroundColorB ?? unselectedBackgroundColor ?? Colors.white,
     selectedRippleColor = rippleColorA ?? selectedRippleColor ?? Colors.white,
     unselectedRippleColor = rippleColorB ?? unselectedRippleColor ?? Colors.black,
     borderRadius = radius ?? borderRadius ?? 2,
     animationDuration = duration ?? animationDuration ?? const Duration(milliseconds: 300),
     isSelected = selected ?? isSelected,
     assert((radius ?? borderRadius ?? 2) >= 2, 'borderRadius debe ser al menos 2.0 para un renderizado correcto');