FormBuilder<T> mixin
FormBuilder is a helper class to handle forms. T stands for the type used to identify the fields
such as an enum or a string to later access each of its fields.
The first step is to call setupForm with a map of the fields, their initial values and validators.
The second step is to call updateAndValidateField or updateField to update the value of each field once it's changed on the UI and present its value on screen by using either the helper functions such as getFieldValue or getFieldErrorMessage or by accessing the inputMap directly.
The third and final step is to call validateForm to validate all fields and use the computed value isFormValid to show a submit button as enabled or disabled and verify the status of the form.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
inputMap
→ ObservableMap<
T, FormItem> -
The map of fields, along with all of their properties
final
- isFormValid → bool
-
The computed value of the form, true if all fields are valid, false otherwise
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getFieldErrorMessage(
dynamic key) → String? - Returns the error message of the field
-
getFieldValue<
V> (dynamic key) → V - Returns the value of the field
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setupForm(
Map< T, FormItem> inputs) → Future<void> - Sets up the form with the given inputs
-
toString(
) → String -
A string representation of this object.
inherited
-
updateAndValidateField(
dynamic newValue, T type) → Future< void> - Updates the value of the field and validates it, updating the computed variable isFormValid
-
updateField(
dynamic newValue, T type) → void - Updates the value of the field without validating it, this does not update the computed variable isFormValid
-
validateForm(
{bool softValidation = false}) → Future< bool> - Validates all fields in the form
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited