FormControl<T> class
A single reactive form control.
A FormControl holds a value of type V, notifies listeners on changes,
and provides validation and state management (required, disabled, readonly).
It can be used with simple values or with a TextEditingController for text fields.
Tis the type stored in the ValueNotifier.
- Inheritance
-
- Object
- ChangeNotifier
- AbstractControl<
T> - FormControl
Constructors
-
FormControl({required T initialValue, FormFieldValidator<
T> ? validator, FormControlOptions? options}) -
Creates a FormControl with the provided valueNotifier,
validator, andoptions.
Properties
- controller → TextEditingController
-
no setter
- disabled → bool
-
Whether the control is disabled.
no setter
- error → String?
-
The validation error message, if any.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- options → FormControlOptions
-
Options to configure control state (required, disabled, readonly).
final
- readonly → bool
-
Whether the control is readonly.
no setter
- required → bool
-
Whether the control is marked as required.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- valid → bool
-
Whether the control is valid (no validation errors).
no setteroverride
-
validator
↔ FormFieldValidator<
T> ? -
The optional validator function to check the control's value.
getter/setter pair
- value → T
-
Returns the current value of the control.
no setteroverride
-
valueNotifier
→ ValueNotifier<
T> -
The underlying value notifier holding the current value.
final
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Disposes the ValueNotifier.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
setDisabled(
bool v, {bool notify = true}) → void - Sets whether the control is disabled.
-
setReadonly(
bool v, {bool notify = true}) → void - Sets whether the control is readonly.
-
setRequired(
bool v, {bool notify = true}) → void - Sets whether the control is marked as required.
-
setValidator(
FormFieldValidator< T> ? newValidator, {bool notify = true}) → void - Updates the validator function. @param newValidator The new validator function to set.
-
setValue(
T val, {bool notify = true}) → void -
Sets the control value, unless disabled or readonly.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited