RectRevealButton constructor
const
RectRevealButton({
- Key? key,
- required Widget selectedChild,
- Widget? unselectedChild,
- required VoidCallback onPressed,
- Color? selectedBackgroundColor,
- Color? unselectedBackgroundColor,
- Color? selectedRippleColor,
- Color? unselectedRippleColor,
- double width = double.infinity,
- double height = 48,
- double? borderRadius,
- Duration? animationDuration,
- bool? isSelected,
- BoxBorder? border,
- EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 16),
- AlignmentGeometry alignment = Alignment.center,
- RevealDirection 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,
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');