ValidatingTextController class

A TextEditingController that validates its text on every change and exposes the validation result via an error notifier.

Provide an optional validator function. It receives the current text and returns an error message string if the value is invalid, or null if valid.

Constructors

ValidatingTextController({String? text, String? validator(String)?})

Properties

error → ValueListenable<String?>
A ValueListenable that emits error messages (or null) as the text changes.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selection ↔ TextSelection
The current selection.
getter/setter pairinherited
text String
The current text being edited.
getter/setter pairinherited

Methods

addListener(VoidCallback listener) → void
Add a listener.
inherited
clear() → void
Clear the text.
inherited
dispose() → void
Dispose of the controller.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Notify all listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a listener.
inherited
setValidator(String? validator(String)?) → void
Replaces the validator function. Runs validation immediately.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited