FormController<Success, Failure extends Error> mixin

A mixin to manage the state and logic of a form.

The mixin defines methods for updating fields, validating the form, and handling form submission.

Type Parameters:

  • Success: The data type that represents the result of a successful form submission.
  • Failure: The error type that extends Error representing the failure cases of form submission.
Mixin applications
Available extensions

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 pair
stopOnFirstError bool
A flag indicating if the validation should stop on encountering the first error.
getter/setter pair

Methods

clear() → void
Clears the form state and resets it to its initial pristine state.
fields() Map<String, FormFieldState>
Returns the map of field names to their corresponding FormFieldState.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onSubmit() Future<Success>
To be implemented by the subclass, detailing what should happen when a form is submitted.
setError(String fieldName, String error) → void
Sets an error message for the specified field and updates the form state to invalid.
submit() Future<void>
Initiates the form submission process.
toggleCheckbox<T>(String fieldName, {required T value, bool? selected}) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Toggles the value of a specific checkbox within a checkbox group.
toString() String
A string representation of this object.
inherited
update<T extends FormFieldState<G>, G>(String fieldName, G value) → void
Updates the field value and status.
updateAsyncDropDown<T>(String fieldName, T value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a AsyncDropDownFieldState with a given value.
updateCheckbox(String fieldName, bool value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a CheckboxFieldState with a given value.
updateCheckboxGroup<T>(String fieldName, Set<T> value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a CheckboxGroupFieldState with a given value.
updateDate(String fieldName, DateTime? value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a DateFieldState with a given value.
updateDropDown<T>(String fieldName, T value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a DropDownFieldState with a given value.
updateError(String fieldName, String error) → void
Updates the error message for the specified field and performs additional validation.
updateFile(String fieldName, File? value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a FileFieldState with a given value.
updateHiddenField<T>(String fieldName, T value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a HiddenFieldState with a given value.
updateRadioButton<T>(String fieldName, T value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a RadioButtonFieldState with a given value.
updateRadioGroup<T>(String fieldName, T value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a RadioGroupFieldState with a given value.
updateText(String fieldName, String? value) → void

Available on FormController<dynamic, Error>, provided by the XFormController extension

Updates a TextFieldState with a given value.
validate() → void
Validates all fields in the form.

Operators

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