AnimatedStateButton constructor
- Key? key,
- double? width,
- required AnimatedStateButtonController controller,
- Future<
void> onPressed()?, - Widget? initChild,
- Color initColor = Colors.black,
- double borderRadius = 8,
- EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16),
- double height = 48,
- double compactSize = 48,
- Duration animationDuration = const Duration(milliseconds: 400),
- Curve animationCurve = Curves.easeInOut,
- Duration switchDuration = const Duration(milliseconds: 300),
- Curve switchInCurve = Curves.easeOut,
- Curve switchOutCurve = Curves.easeIn,
- ButtonStyle? buttonStyle,
- bool enabled = true,
- double? elevation,
- Color? shadowColor,
Crea un AnimatedStateButton.
controller es requerido para manejar los estados del botón.
width define el ancho del botón en estado inicial. Si es null,
usa el ancho disponible menos el padding horizontal (por defecto).
onPressed es la acción a ejecutar al presionar el botón.
Si es null, ejecuta una animación de demostración.
initChild es el widget mostrado en estado inicial.
Por defecto muestra el texto 'Enviar'.
initColor es el color de fondo en estado inicial.
borderRadius define el radio de las esquinas del botón en estado inicial.
height es la altura del botón (constante en todos los estados).
compactSize es el tamaño del botón cuando está en estado compacto.
animationDuration controla la duración de la animación de cambio de tamaño.
switchDuration controla la duración de la transición entre widgets.
enabled controla si el botón está habilitado o deshabilitado.
elevation y shadowColor configuran la sombra del botón.
Implementation
const AnimatedStateButton({
super.key,
this.width,
required this.controller,
this.onPressed,
this.initChild,
this.initColor = Colors.black,
this.borderRadius = 8,
this.padding = const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16),
this.height = 48,
this.compactSize = 48,
this.animationDuration = const Duration(milliseconds: 400),
this.animationCurve = Curves.easeInOut,
this.switchDuration = const Duration(milliseconds: 300),
this.switchInCurve = Curves.easeOut,
this.switchOutCurve = Curves.easeIn,
this.buttonStyle,
this.enabled = true,
this.elevation,
this.shadowColor,
}) : assert(height > 0, 'La altura debe ser mayor a 0'),
assert(compactSize > 0, 'El tamaño compacto debe ser mayor a 0');