FormController<Success, Failure extends Error> mixin
A mixin to extend the functionality of a form controller by inheriting the base methods for managing form state, field updates, validation, and form submission.
The FormController provides a simplified way to manage forms, ensuring
that all the fundamental functionalities such as updating fields, validating
input, and handling form submission are readily available. It extends the
BaseFormController to provide these core capabilities.
Type Parameters:
SuccessThe data type that represents the result of a successful form submission.FailureThe error type that extends Error representing the failure cases of form submission.
Usage: Use this mixin with any class that needs to manage form state and logic. This mixin provides all essential methods and properties for interacting with a form's fields and its state, allowing for a streamlined implementation.
- Superclass constraints
- BaseFormController<
Success, Failure, BondFormState< Success, Failure> > - FieldChangeTrackingMixin<
Success, Failure>
- BaseFormController<
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
↔ BondFormState<
Success, Failure> -
Returns the current state of the form.
getter/setter pairinherited
- stopOnFirstError ↔ bool
-
A flag indicating if the validation should stop on encountering the first error.
getter/setter pairinherited
Methods
-
addFieldListener<
T> (String fieldName, void listener(T)) → void -
Add a listener for a specific field's changes and returns the current field value
inherited
-
clear(
) → void -
Clears the form state and resets it to its initial pristine state.
override
-
dispose(
) → void - Disposes resources used by the form controller.
-
disposeTracking(
) → void -
Cleans up tracking resources
inherited
-
fields(
) → Map< String, FormFieldState> -
Returns the map of field names to their corresponding
FormFieldState.inherited -
initializeFieldTracking(
) → void -
Initialize field tracking for change detection
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyFieldListeners<
T> (String field, T value) → void -
Called when a field is updated to notify any registered listeners
inherited
-
onFailure(
Failure error) → void -
Called when form submission fails. Can be overridden.
inherited
-
onSubmit(
) → Future< Success> -
To be implemented by the subclass, detailing what should happen when a form is submitted.
inherited
-
onSuccess(
Success result) → void -
Called when the form is successfully submitted. Can be overridden.
inherited
-
removeFieldListener<
T> (String fieldName, void listener(T)) → void -
Remove a listener for a specific field's changes
inherited
-
resetInitialFieldsValue(
) → void -
resets the initial field values
inherited
-
setError(
String fieldName, String? error) → void -
Sets an error message for the specified field and updates the form state to invalid.
inherited
-
submit(
) → Future< void> -
Initiates the form submission process.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateError(
String fieldName, String error) → void -
Updates the error message for the specified field and performs additional validation.
inherited
-
updateValue<
T extends FormFieldState< (G> , G>String fieldName, G value) → void -
Updates the field value and notifies any registered listeners
override
-
validate(
) → void -
Validates all fields in the form.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited