FormGroup<M> class
abstract
A reactive group of form controls.
A FormGroup holds a collection of FormControl or other nested FormGroup
instances, and provides utilities to read, set, validate and convert form data.
M is the type of the model this group maps to.
- Inheritance
-
- Object
- ChangeNotifier
- AbstractControl<
Map< String, dynamic> > - FormGroup
Constructors
-
FormGroup(Map<
String, AbstractControl> controls) - Creates a FormGroup with the provided controls.
Properties
-
controls
→ Map<
String, AbstractControl> -
The map of controls registered in this group.
final
- deps ↔ FormDeps
-
latefinal
- error → String?
-
Returns the first validation error found among the controls.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- listenValueOnly ↔ bool
-
getter/setter pair
- propagateChanges → bool
-
Whether the group is currently listening to value changes in child controls.
no setter
- rules ↔ FormRules
-
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- valid → bool
-
Whether all controls in the group are valid.
no setteroverride
-
value
→ Map<
String, dynamic> -
Returns the current value of the group as a map.
no setteroverride
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
contains(
String name) → bool -
Returns whether the control with
nameexists in this group. -
control<
T> (String name) → FormControl< T> -
Returns a FormControl with the given
name. -
dispose(
) → void -
Disposes all child controls and this group.
override
-
fromModel(
M model) → void -
Converts the form group from a model of type
M. -
getRawValue(
{bool flatten = true}) → Map< String, dynamic> -
Builds a raw value map for all controls in this group.
When
flattenis enabled, values from nested groups are flattened into the parent map; otherwise, the nested structure is preserved.override -
group<
T extends FormGroup> (String name) → T -
Returns the nested FormGroup with the given
name. -
listenControls(
bool listenValueOnly) → void - Starts listening to all child controls' value changes to notify listeners.
-
markAllAsTouched(
{bool notify = true}) → void - Marks all controls in the group as touched.
-
markAllAsUntouched(
{bool notify = true}) → void - Marks all controls in the group as untouched.
-
nestedControl<
T> (String name) → AbstractControl< T> -
Returns the AbstractControl with the given
name, supporting nested paths. E.g. "address.street" will return the "street" control inside the "address" group. Supports multiple levels of nesting. Throws if any part of the path is invalid. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
refreshAll(
) → void - Recursively refreshes all controls and nested groups.
-
register(
String name, AbstractControl control) → void -
Registers a new
controlunder the givenname. -
registerAll(
Map< String, AbstractControl> newControls) → void - Registers multiple controls at once.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
setRawValue(
Object? raw, {bool notify = true}) → void -
Recursively applies a raw value map to this group and its nested groups.
override
-
setValue(
Map< String, dynamic> val, {bool notify = true}) → void -
Sets the values of all controls from the provided map
val.override -
toModel(
) → FutureOr< M> -
Converts the form group to a model of type
M. -
toString(
) → String -
A string representation of this object.
inherited
-
validateResult(
) → AsyncResult< FormGroup< M> > -
Validates the form group and returns a
Result.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited