DynamicFormController class
Controls values, validation, and events for a FormSchema-driven form.
- Inheritance
-
- Object
- ChangeNotifier
- DynamicFormController
Constructors
-
DynamicFormController({Map<
String, FieldValidator> ? customValidators, Map<String, AsyncFieldValidator> ? asyncValidators, ServerFieldValidator? serverValidator, ConditionEvaluator conditionEvaluator = const ConditionEvaluator()}) - Creates a DynamicFormController.
Properties
-
errors
→ Map<
String, String> -
Immutable copy of current errors.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isDirty → bool
-
Whether any value changed since bind / reset.
no setter
- isSubmitting → bool
-
Whether submit is running.
no setter
- isValid → bool
-
Whether there are currently no validation errors.
no setter
- isValidating → bool
-
Whether async validation is running.
no setter
-
nestedValues
→ Map<
String, dynamic> -
Nested values: group children nested under the group key.
no setter
-
onChanged
↔ void Function(Map<
String, dynamic> values)? -
Called when the full values map changes.
getter/setter pair
- onFieldChanged ↔ void Function(String key, dynamic value)?
-
Called when any field value changes.
getter/setter pair
-
onSaved
↔ void Function(Map<
String, dynamic> values)? -
Called after values are saved / collected (alias of successful submit).
getter/setter pair
-
onSubmit
↔ void Function(Map<
String, dynamic> values)? -
Called after a successful submit when validation passes.
getter/setter pair
-
onValidationFailed
↔ void Function(Map<
String, String> errors)? -
Called when validation fails.
getter/setter pair
-
onValidationSuccess
↔ void Function(Map<
String, dynamic> values)? -
Called when validation succeeds.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schema → FormSchema?
-
Bound schema (set by DynamicForm or manually via bind).
no setter
- state → DynamicFormState
-
Combined state snapshot.
no setter
-
values
→ Map<
String, dynamic> -
Immutable copy of current values.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addRepeatableItem(
String key, {Map< String, dynamic> ? values}) → void - Appends an item to a FieldType.repeatable field.
-
bind(
FormSchema schema, {bool resetValues = true}) → void - Binds a schema and seeds default values.
-
clear(
) → void - Clears all leaf values and errors.
-
dispose(
) → void -
Discards any resources used by the object.
override
-
errorFor(
String key) → String? -
Error message for
key, if any. -
fieldFor(
String key) → FormFieldSchema? -
Field schema for
key, if bound. -
getValue(
String key) → dynamic -
Returns the value for
key. -
isEnabled(
String key) → bool - Convenience: enabled by key.
-
isFieldEnabled(
FormFieldSchema field) → bool -
Whether
fieldis currently enabled given schema + conditions. -
isFieldVisible(
FormFieldSchema field) → bool -
Whether
fieldis currently visible given schema + conditions. -
isVisible(
String key) → bool - Convenience: visibility by key.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
patchValues(
Map< String, dynamic> patch, {bool validate = false}) → void - Patches multiple values at once.
-
registerAsyncValidator(
String name, AsyncFieldValidator validator) → void - Registers or replaces a named async validator.
-
registerValidator(
String name, FieldValidator validator) → void - Registers or replaces a named sync custom validator.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeRepeatableItem(
String key, int index) → void -
Removes a repeatable item at
index. -
reset(
) → void - Resets values to schema defaults and clears errors / dirty flag.
-
setServerValidator(
ServerFieldValidator? validator) → void -
Sets the global server validator used by
type: serverrules. -
submit(
{bool nestGroups = false}) → Future< bool> - Validates (including async) and invokes submit callbacks on success.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateField(
String key, dynamic value, {bool validate = true, bool notifyListeners = true}) → void - Updates a single field and optionally validates it (sync rules only).
-
updateRepeatableItemField(
String key, int index, String childKey, dynamic value) → void - Updates a nested value inside a repeatable item.
-
validate(
{bool notify = true}) → bool - Validates all visible leaf fields synchronously.
-
validateAsync(
{bool notify = true}) → Future< bool> - Runs sync + async/server validators for all visible fields.
-
validateField(
String key, {bool notify = true}) → bool - Validates a single field synchronously (skips async/server rules).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited