FormController class

Stateful helper for form data, validation errors, and submit lifecycle.

Constructors

FormController(Map<String, Object?> initialValues)
Creates a form controller from initial field values.

Properties

data Map<String, Object?>
Immutable snapshot of current form data.
no setter
errors FormErrors
Current validation errors keyed by field name.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
processing bool
Whether a submit action is currently running.
getter/setter pair
recentlySuccessful bool
Whether the form has recently completed a successful submit.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
wasSuccessful bool
Whether the most recent submit completed successfully.
getter/setter pair

Methods

addListener(FlintVoidCallback listener) → void
Registers a listener called whenever form state changes.
clearErrors([List<String> keys = const []]) → void
Clears all validation errors, or only errors for keys.
controller(String key) TextEditingController
Returns a text controller synchronized with the field named key.
error(String key) String?
Returns the first validation message for key, if any.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeListener(FlintVoidCallback listener) → void
Removes a previously registered form state listener.
reset([List<String> keys = const []]) → void
Resets all fields, or only keys, to their initial values.
setError(String key, Object message) → void
Adds a validation error for one field.
setErrors(Object? messages) → void
Replaces validation errors from a supported error payload.
setField(String key, Object? value) → void
Updates one field value and notifies listeners.
string(String key) String
Gets the field value for key as a string.
submit<T>(Future<T> action(Map<String, Object?> data), {void onSuccess(T result)?, void onError(Object error)?, void onValidationError(FormErrors errors)?, bool resetOnSuccess = false}) Future<T?>
Runs action with current data and updates submit state.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String key) Object?
Gets the raw value for key.