BaseFormController<Success, Failure extends Error, State extends BaseBondFormState<Success, Failure>> mixin

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

This mixin provides foundational methods for managing form state, updating fields, validating the form, and handling form submission. It is intended to be used by form controllers that manage individual or stepper-based forms.

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.
  • State The state type extending BaseBondFormState that holds the form's fields and submission status.
Mixin applications
Available extensions
  1. @protected

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 ↔ State
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.
insertAsyncDropDownItem<T>(String fieldName, {required T value, required String label, int index = 0}) → void

Available on BaseFormController<Success, Failure, State>, provided by the FormControllerUpdateItemsExtension extension

Inserts a new value into the items list of an AsyncDropDownFieldState.
insertAsyncRadioItem<T>(String fieldName, {required T value, required String label, int index = 0}) → void

Available on BaseFormController<Success, Failure, State>, provided by the FormControllerUpdateItemsExtension extension

Inserts a new radio button item into the cached items of an async radio group field.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFailure(Failure error) → void
Called when form submission fails. Can be overridden.
onSubmit() Future<Success>
To be implemented by the subclass, detailing what should happen when a form is submitted.
onSuccess(Success result) → void
Called when the form is successfully submitted. Can be overridden.
removeTextFieldFocusListener(String fieldName) → void

Available on BaseFormController<Success, Failure, State>, provided by the TextFieldFormController extension

Removes the focus listener for the specified text field. This is useful when cleaning up resources, such as during onClose() in a controller.
removeTextFieldListener(String fieldName) → void

Available on BaseFormController<Success, Failure, State>, provided by the TextFieldFormController extension

Remove the listener registered for the given text field, if any.
replaceAsyncDropDownItems<T>(String fieldName, List<DropDownItemState<T>> items) → void

Available on BaseFormController<Success, Failure, State>, provided by the FormControllerUpdateItemsExtension extension

Replaces all existing cached dropdown items with a new list of items.
replaceAsyncRadioItems<T>(String fieldName, List<RadioButtonFieldState<T>> items) → void

Available on BaseFormController<Success, Failure, State>, provided by the FormControllerUpdateItemsExtension extension

Replaces all cached radio button items in an async radio group field with a new list.
resolveAsyncField<T>(String fieldName) Future<T>

Available on BaseFormController<dynamic, Error, BaseBondFormState<dynamic, Error>>, provided by the AsyncFieldFormController extension

Resolves the value of an asynchronous hidden field and updates its state.
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.
textFieldController(String fieldName) TextEditingController

Available on BaseFormController<Success, Failure, State>, provided by the TextFieldFormController extension

Retrieves the TextEditingController for a given text field and ensures it is observed.
textFieldFocusNode(String fieldName) FocusNode

Available on BaseFormController<Success, Failure, State>, provided by the TextFieldFormController extension

Retrieves the FocusNode for a given text field.
toggleCheckbox<T>(String fieldName, {required T value, bool? selected}) → void

Available on BaseFormController<dynamic, Error, BaseBondFormState<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
updateAsyncDropDown<T>(String fieldName, T value) → void

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

Updates a AsyncDropDownFieldState with a given value.
updateAsyncDropDownItem<T>(String fieldName, {required T value, required String label}) → void

Available on BaseFormController<Success, Failure, State>, provided by the FormControllerUpdateItemsExtension extension

Updates an existing dropdown item in an AsyncDropDownFieldState by its value.
updateAsyncHiddenField<T>(String fieldName, T value) → void

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

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

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

Updates an AsyncRadioGroupFieldState with a given value.
updateAsyncRadioItem<T>(String fieldName, {required T value, required String label}) → void

Available on BaseFormController<Success, Failure, State>, provided by the FormControllerUpdateItemsExtension extension

Updates the label of an existing radio button item in an async radio group field by its value.
updateCheckbox(String fieldName, bool value) → void

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

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

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

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

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

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

Available on BaseFormController<dynamic, Error, BaseBondFormState<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 BaseFormController<dynamic, Error, BaseBondFormState<dynamic, Error>>, provided by the XFormController extension

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

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

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

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

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

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

Updates a RadioGroupFieldState with a given value.
updateRadioGroupItems<T>(String fieldName, List<RadioButtonFieldState<T>> items) → void

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

Updates a RadioGroupFieldState with a list of RadioButtonFieldState items.
updateText(String fieldName, String? value) → void

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

Updates a TextFieldState with a given value.
updateValue<T extends FormFieldState<G>, G>(String fieldName, G value) → void
Updates the field value and status.
validate() → void
Validates all fields in the form.

Operators

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