FabrikForm class
Represents a form composed of multiple named FabrikFields.
Provides centralized access to field values, validation state, and form-wide actions like updating values or marking fields as touched.
A form is deliberately untyped: each field carries its own type and its own
validators, so a single form can mix a String email, an int age and a
bool opt-in. Types are recovered at the call site with get:
final form = FabrikForm({
'email': FabrikField<String>(value: '', validators: [EmailValidator()]),
'age': FabrikField<int>(value: 0, validators: [RangeValidator(min: 18, max: 120)]),
'subscribed': FabrikField<bool>(value: false),
});
form.get<String>('email').value; // String
form.get<int>('age').value; // int
Constructors
-
FabrikForm(Map<
String, FabrikField> fields, {List<FabrikFormValidator> ? validators}) - Creates a new FabrikForm from a map of field keys to FabrikFields.
Properties
-
allErrors
→ Map<
String, List< String> > -
Every validation error for each field, keyed by field name.
no setter
-
errors
→ Map<
String, String?> -
The first validation error for each field, keyed by field name.
no setter
- formError → String?
-
The first form-level error, or
nullwhen the form-level rules pass.no setter -
formErrors
→ List<
String> -
Every form-level error, in validator order.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDirty → bool
-
Whether any field in the form has changed from its initial value.
no setter
- isTouched → bool
-
Whether the user has interacted with any field in the form.
no setter
- isValid → bool
-
Whether every field is valid and all form-level validators pass.
no setter
-
keys
→ Iterable<
String> -
The field keys in this form, in insertion order.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ Map<
String, dynamic> -
The current values of all fields in the form.
no setter
Methods
-
contains(
String key) → bool -
Whether a field with
keyexists in this form. -
get<
T> (String key) → FabrikField< T> -
Retrieves a field by key, typed as FabrikField of
T. -
markAllTouched(
) → void - Marks all fields as touched and revalidates them.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Resets all fields to their initial values and clears all interaction state.
-
toString(
) → String -
A string representation of this object.
inherited
-
update<
T> (String key, T value) → void - Updates the value of a specific field by key.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited