'How to get error message of validator from TextFormField
I want to get error message programmatically to display somewhere else. Example error show Text is too short, I can get it by using _formKey.currentState... . How to get there?
Form(
key: _formKey,
child: TextFormField(
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
if (value.length < 5 ) {
return 'Text is too short';
}
return null;
},
),
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
