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:
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.StateThe state type extending BaseBondFormState that holds the form's fields and submission status.
- 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 ↔ 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<
Inserts a newSuccess, Failure, State> , provided by the FormControllerUpdateItemsExtension extensionvalueinto the items list of an AsyncDropDownFieldState. -
insertAsyncRadioItem<
T> (String fieldName, {required T value, required String label, int index = 0}) → void -
Available on BaseFormController<
Inserts a new radio button item into the cached items of an async radio group field.Success, Failure, State> , provided by the FormControllerUpdateItemsExtension extension -
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<
Removes the focus listener for the specified text field. This is useful when cleaning up resources, such as duringSuccess, Failure, State> , provided by the TextFieldFormController extensiononClose()in a controller. -
removeTextFieldListener(
String fieldName) → void -
Available on BaseFormController<
Remove the listener registered for the given text field, if any.Success, Failure, State> , provided by the TextFieldFormController extension -
replaceAsyncDropDownItems<
T> (String fieldName, List< DropDownItemState< items) → voidT> > -
Available on BaseFormController<
Replaces all existing cached dropdown items with a new list of items.Success, Failure, State> , provided by the FormControllerUpdateItemsExtension extension -
replaceAsyncRadioItems<
T> (String fieldName, List< RadioButtonFieldState< items) → voidT> > -
Available on BaseFormController<
Replaces all cached radio button items in an async radio group field with a new list.Success, Failure, State> , provided by the FormControllerUpdateItemsExtension extension -
resolveAsyncField<
T> (String fieldName) → Future< T> -
Available on BaseFormController<
Resolves the value of an asynchronous hidden field and updates its state.dynamic, Error, BaseBondFormState< , provided by the AsyncFieldFormController extensiondynamic, Error> > -
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<
Retrieves the TextEditingController for a given text field and ensures it is observed.Success, Failure, State> , provided by the TextFieldFormController extension -
textFieldFocusNode(
String fieldName) → FocusNode -
Available on BaseFormController<
Retrieves the FocusNode for a given text field.Success, Failure, State> , provided by the TextFieldFormController extension -
toggleCheckbox<
T> (String fieldName, {required T value, bool? selected}) → void -
Available on BaseFormController<
Toggles the value of a specific checkbox within a checkbox group.dynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> > -
toString(
) → String -
A string representation of this object.
inherited
-
updateAsyncDropDown<
T> (String fieldName, T value) → void -
Available on BaseFormController<
Updates a AsyncDropDownFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateAsyncDropDownItem<
T> (String fieldName, {required T value, required String label}) → void -
Available on BaseFormController<
Updates an existing dropdown item in an AsyncDropDownFieldState by its value.Success, Failure, State> , provided by the FormControllerUpdateItemsExtension extension -
updateAsyncHiddenField<
T> (String fieldName, T value) → void -
Available on BaseFormController<
Updates a AsyncHiddenFieldState with a given value.dynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> > -
updateAsyncRadioGroup<
T> (String fieldName, T value) → void -
Available on BaseFormController<
Updates an AsyncRadioGroupFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateAsyncRadioItem<
T> (String fieldName, {required T value, required String label}) → void -
Available on BaseFormController<
Updates the label of an existing radio button item in an async radio group field by its value.Success, Failure, State> , provided by the FormControllerUpdateItemsExtension extension -
updateCheckbox(
String fieldName, bool value) → void -
Available on BaseFormController<
Updates a CheckboxFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateCheckboxGroup<
T> (String fieldName, Set< T> value) → void -
Available on BaseFormController<
Updates a CheckboxGroupFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateDate(
String fieldName, DateTime? value) → void -
Available on BaseFormController<
Updates a DateFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateDropDown<
T> (String fieldName, T value) → void -
Available on BaseFormController<
Updates a DropDownFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >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<
Updates a FileFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateHiddenField<
T> (String fieldName, T value) → void -
Available on BaseFormController<
Updates a HiddenFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateRadioButton<
T> (String fieldName, T value) → void -
Available on BaseFormController<
Updates a RadioButtonFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateRadioGroup<
T> (String fieldName, T value) → void -
Available on BaseFormController<
Updates a RadioGroupFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >value. -
updateRadioGroupItems<
T> (String fieldName, List< RadioButtonFieldState< items) → voidT> > -
Available on BaseFormController<
Updates a RadioGroupFieldState with a list of RadioButtonFieldState items.dynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> > -
updateText(
String fieldName, String? value) → void -
Available on BaseFormController<
Updates a TextFieldState with a givendynamic, Error, BaseBondFormState< , provided by the XFormController extensiondynamic, Error> >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