AnimatedFormSlot<T> constructor
- Key? key,
- required Signal<
T> connect, - required Widget to(
- BuildContext context,
- T value,
- FormValidationResult validation,
- bool isFocused,
- String? validator(
- T value
- Signal<
String?> ? errorSignal, - Signal<
bool> ? focusedSignal, - FormAnimationEffect errorEffect = FormAnimationEffect.shake,
- FormAnimationEffect successEffect = FormAnimationEffect.pulse,
- Duration animationDuration = const Duration(milliseconds: 300),
- Curve animationCurve = Curves.easeInOut,
- bool validateOnChange = true,
- bool showSuccessAnimation = true,
- Duration validationDelay = Duration.zero,
- void onValidationChanged(
- FormValidationResult result
Creates an AnimatedFormSlot for form fields with validation animations.
Basic Usage
AnimatedFormSlot<String>(
connect: controller.email,
validator: (value) => value.isEmpty ? 'Required' : null,
to: (context, value, validation, isFocused) => TextField(
onChanged: (v) => controller.email.emit(v),
decoration: InputDecoration(
errorText: validation.errorMessage,
),
),
)
With Animation Effects
AnimatedFormSlot<String>(
connect: controller.password,
validator: (v) => v.length < 8 ? 'Min 8 chars' : null,
errorEffect: FormAnimationEffect.shake,
successEffect: FormAnimationEffect.pulse,
showSuccessAnimation: true,
to: (context, value, validation, isFocused) => ...
)
Best practices:
- Use
validationDelayfor debounced validation on text fields - Connect
errorSignalto display errors elsewhere in the UI - Use
focusedSignalto style focused fields differently
Implementation
const AnimatedFormSlot({
super.key,
required this.connect,
required this.to,
this.validator,
this.errorSignal,
this.focusedSignal,
this.errorEffect = FormAnimationEffect.shake,
this.successEffect = FormAnimationEffect.pulse,
this.animationDuration = const Duration(milliseconds: 300),
this.animationCurve = Curves.easeInOut,
this.validateOnChange = true,
this.showSuccessAnimation = true,
this.validationDelay = Duration.zero,
this.onValidationChanged,
});