FormControl<T, V> 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.
T
is the type stored in the ValueNotifier.V
is the external representation of the value.
- Inheritance
-
- Object
- ChangeNotifier
- AbstractControl<
V> - FormControl
Properties
- controller → TextEditingController
-
Returns the TextEditingController if this control manages text.
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
- isDisabled ↔ bool
-
Whether the control is disabled.
getter/setter pair
- isReadonly ↔ bool
-
Whether the control is readonly.
getter/setter pair
- isRequired ↔ bool
-
Whether the control is marked as required.
getter/setter pair
- options → FormControlOptions
-
Options to configure control state (required, disabled, readonly).
final
- 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<
V> ? -
The optional validator function to check the control's value.
final
- value → V
-
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
-
setValue(
V val) → 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
Static Methods
-
create<
T> ({required T initialValue, FormFieldValidator< T> ? validator, FormControlOptions? options}) → FormControl<T, T> - Creates a FormControl for any generic type.
-
text(
{required String? initialValue, FormFieldValidator< String> ? validator, FormControlOptions? options}) → FormControl<TextEditingValue, String> - Creates a FormControl specialized for text input.