AnimatedFormSlot<T> class

AnimatedFormSlot - Reactive form field with built-in animations.

Provides animated feedback for form field states including validation, focus, and error animations. Supports shake on error, pulse on success, and smooth error message transitions.

Example:

class LoginController extends NeuronController {
  late final email = Signal<String>('').bind(this);
  late final emailError = Signal<String?>('').bind(this);
  late final emailFocused = Signal<bool>(false).bind(this);

  static final _emailRegex = RegExp(
    r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
  );

  String? validateEmail(String value) {
    if (value.isEmpty) return 'Email is required';
    if (!_emailRegex.hasMatch(value)) return 'Invalid email format';
    return null;
  }
}

// In your widget:
AnimatedFormSlot<String>(
  connect: controller.email,
  validator: controller.validateEmail,
  errorSignal: controller.emailError,
  focusedSignal: controller.emailFocused,
  errorEffect: FormAnimationEffect.shake,
  successEffect: FormAnimationEffect.pulse,
  to: (context, value, validation, isFocused) => TextField(
    onChanged: (v) => controller.email.emit(v),
    decoration: InputDecoration(
      labelText: 'Email',
      errorText: validation.errorMessage,
      border: OutlineInputBorder(
        borderSide: BorderSide(
          color: validation.isValid ? Colors.green : Colors.red,
        ),
      ),
    ),
  ),
)
Inheritance
Available extensions

Constructors

AnimatedFormSlot({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.
const

Properties

animationCurve Curve
Curve for animations
final
animationDuration Duration
Duration for animations
final
connect Signal<T>
The signal containing the form field value
final
errorEffect FormAnimationEffect
Animation effect for error state
final
errorSignal Signal<String?>?
Optional signal to emit error messages to
final
focusedSignal Signal<bool>?
Optional signal to track focus state
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onValidationChanged → void Function(FormValidationResult result)?
Callback when validation state changes
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showSuccessAnimation bool
Whether to show success animation
final
successEffect FormAnimationEffect
Animation effect for success state
final
to Widget Function(BuildContext context, T value, FormValidationResult validation, bool isFocused)
Builder function for the form field widget
final
validateOnChange bool
Whether to validate on every change
final
validationDelay Duration
Delay before validation after change
final
validator String? Function(T value)?
Optional validator function
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<AnimatedFormSlot<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onTap(VoidCallback onTap, {double pressedScale = 0.95}) Widget

Available on Widget, provided by the SlotWidgetModifiers extension

Wrap with tap gesture.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited
withDelay(Duration delay) Widget

Available on Widget, provided by the SlotWidgetModifiers extension

Add a delay before showing.
withFade({Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.easeInOut}) Widget

Available on Widget, provided by the SlotWidgetModifiers extension

Wrap with fade animation on appear.
withHero(Object tag) Widget

Available on Widget, provided by the SlotWidgetModifiers extension

Wrap with hero animation.
withScale({double begin = 0.8, double end = 1.0, Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.easeOutBack}) Widget

Available on Widget, provided by the SlotWidgetModifiers extension

Wrap with scale animation on appear.
withShimmer({Duration duration = const Duration(milliseconds: 1500), Color baseColor = const Color(0xFFE0E0E0), Color highlightColor = const Color(0xFFF5F5F5)}) Widget

Available on Widget, provided by the SlotWidgetModifiers extension

Apply a shimmer loading effect.
withSlide({Offset begin = const Offset(0, 0.2), Offset end = Offset.zero, Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.easeOutCubic}) Widget

Available on Widget, provided by the SlotWidgetModifiers extension

Wrap with slide animation on appear.

Operators

operator ==(Object other) bool
The equality operator.
inherited