BloomFormField class

Reactive state controller for an individual string form input field.

Tracks input state, error messages, dirty/touched flags, and validation status using fine-grained signals primitives. Supports both synchronous validators and asynchronous validators with debouncing and stale-result discard.

Validation Timing

Setting the field value via setValue updates value and marks isDirty as true, but does not run validators automatically. Validation runs when validate, validateAsync, or validateDebounced is explicitly invoked.

Reactive State

  • value: Current string value as a Signal<String>.
  • errors: List of active validation error strings as a Signal<List<String>>.
  • isDirty: true if setValue has been called since instantiation or reset.
  • isTouched: true after touch is called (e.g. on blur).
  • isValid: Computed ReadonlySignal<bool> that evaluates to true when errors is empty.
  • isValidating: Reactive ReadonlySignal<bool> indicating whether async checks are in flight.
final username = BloomFormField(
  initialValue: '',
  validators: [required(), minLength(3)],
  asyncValidators: [
    (val) async => await api.isAvailable(val) ? null : 'Username is taken.',
  ],
);
Implemented types

Constructors

BloomFormField({String initialValue = '', List<String? Function(String)> validators = const [], List<Future<String?> Function(String)> asyncValidators = const [], Duration asyncDebounce = const Duration(milliseconds: 300)})
Creates a form field controller with optional initialValue, validators, and asyncValidators.

Properties

asyncDebounce Duration
Debounce duration applied when validateAsync is called with debounce: true.
final
asyncValidators List<Future<String?> Function(String)>
Ordered list of asynchronous validator callbacks evaluated on validateAsync.
final
errors Signal<List<String>>
Reactive signal containing validation error messages generated by validate or validateAsync.
latefinaloverride-getter
hashCode int
The hash code for this object.
no setterinherited
isDirty Signal<bool>
Reactive signal indicating whether setValue has modified the initial value.
latefinaloverride-getter
isTouched Signal<bool>
Reactive signal indicating whether the user has interacted with or blurred this field.
latefinaloverride-getter
isValid ReadonlySignal<bool>
Computed signal that evaluates to true when errors is empty.
latefinaloverride-getter
isValidating ReadonlySignal<bool>
Reactive signal indicating whether asynchronous validation is currently executing.
latefinal
rawValue → dynamic
Untyped access to the string value.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
validators List<String? Function(String)>
Ordered list of synchronous validator callbacks evaluated on validate or validateAsync.
final
value Signal<String>
Reactive signal containing the current field value.
latefinal

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Resets value back to its initial value, clears errors, and sets isDirty and isTouched to false.
override
setValue(String newValue) → void
Updates the field's value and marks isDirty as true.
toString() String
A string representation of this object.
inherited
touch() → void
Marks isTouched as true to indicate user interaction (e.g. on blur).
override
validate() bool
Runs all validators against the current value synchronously and updates errors.
override
validateAsync({bool debounce = false}) Future<bool>
Runs synchronous validators first, and if they pass, evaluates all asyncValidators.
override
validateDebounced([Duration? delay]) Future<bool>
Triggers debounced asynchronous validation using delay or asyncDebounce.

Operators

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