How to reset error message in TextFormField?

I know this is a simple question but i did not find how to do this. How can i reset error message in TextFormField when the user input something in the field. Something like onchange listener. I notice onChanged is available in TextField but not TextFormField. How can i do this?

final _email = Container(
  child: TextFormField(
    decoration: InputDecoration(labelText: email),
    keyboardType: TextInputType.emailAddress,
    controller: emailController,
    validator: _validateEmail,
    onSaved: (input) => _stringEmail = input.toLowerCase().trim(),

UPDATE: I am using controller to add listener for user input. But i just want to reset the error message instead of validating the form again. Is this possible? How can i do this?

  _resetEmailErrorMessage() {
    print("Second text field: ${emailController.text}");
    //replace clear to something that can reset the validation error message

  void initState() {

    //start listening to changes

You can use auto-validation feature of Form

If you looking for this solution,

"As soon as you type it validates your input and show/hide error"

Flutter provides auto-validation feature, you just need to enable it at form level.

  1. Default

    _autoValidate = false;

  2. Form

    body: Form( key: _formKey,
                autovalidate: _autoValidate,....)
  1. Enable it when user presses submit once,
    if (_formKey.currentState.validate()) {
      // All Good
    } else {
      // start auto validate
      setState(() {
        _autoValidate = true;

How to reset error message in TextFormField?, TextField/TextFormField reset issue work-around PR generating errors #17621. Closed. acidjazz opened this issue on May 15, 2018 � 9 comments. Closed� acidjazz changed the title TextField Reset work-around generating errors TextField/TextFormField reset issue work-around PR generating errors May 15, 2018 Copy link Quote reply Author

I would suggest to use the controller and listen to the User input . and whenever he types something you can validate() your form again

TextField/TextFormField reset issue work-around PR generating , Steps to Reproduce Call TextEditingController.clear() Source is available first two taps on IconButton in a Row with a TextFormField #38734. well, it’s quite simple, you just have to use reset method…. just copy and paste this code, it will work 100%. [code]<form id="myForm"> First name: &lt;input type

The TextFormField also has the option of onChanged in that you can try to reset the form validation through the FormKey

final _email = Container(
 child: TextFormField(
 decoration: InputDecoration(labelText: email),
  keyboardType: TextInputType.emailAddress,
  controller: emailController,
  validator: _validateEmail,
  onChanged: (value){
  onSaved: (input) => _stringEmail = 

TextEditingController.clear() throws errors � Issue #35909 � flutter , If it is empty, return a friendly error message. content_copy. TextFormField( // The validator receives the text that the user has entered. Hello, recently I encountered an problem, when I used the widget TextField and TextFormField, when I delete the characters which I typed and leave one character, then I found I could not delete the last character, below is the recurrent

It's work for me.

try to use validate form, like a below


need to define validate field in your TextFormField.

Build a form with validation, API docs for the TextFormField class from the material library, for the Dart The Form simply makes it easier to save, reset, or validate multiple fields at once. To use If the user enters invalid text, the error message returned from the validator � To reset the form, we only need to set our input object back to being empty again. The input value is this.state.inputVal[i] . If i doesn't exist (we haven't typed anything yet into that input) we want the value to be an empty string (instead of null).

// Somewhere in `State` declaration 
final formKey = GlobalKey<FormState>();
bool autovalidate = false;

void build(BuildContext context) {
  return Form(
    key: formKey,
    autovalidate: autovalidate,
    child: Column(
      children: [
          validator: (value) {
            return (value == null || value.isEmpty) ? 'Cannot be empty' : null;
          onChanged: (value) {
            // Call this to refresh autovalidation result
            setState(() {});

void validate() {
  if(formKey.currentState.validate()) {
    // data is valid!
    return true;
  } elsee {
    // Activate autovalidation
    autovalidate = true;
  return false;

TextFormField class - material library, But if the doc is quite clear concerning the implementation of basic forms with TextFormField (check the Taking example on its implementation I will now add new types of form fields. with what Flutter offers already with TextFormField and DropDownFormField widgets. Set the field style (including error, focus, hint etc. )� The Form simply makes it easier to save, reset, or validate multiple fields at once. To use without a Form, pass a GlobalKey to the constructor and use GlobalKey.currentState to save or reset the form field. When a controller is specified, its TextEditingController.text defines the initialValue.

Build a Flutter Form with Custom Input Types - Blogs, with default errorText in English but with ability to include you own error message that will display whenever validation fails. Available built-in� Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.

flutter_form_builder, We will validate all three input data as soon as we click on validate button. Once user submit the form and if there is any validation error then We will There is named parameter 'validation' of TextFormField which is used to� Unable to perform Factory Reset Error: There was a problem resetting your PC, no changes were made Original Title: Resetting to factory settings I'm trying to reset my computer to factory settings to have a fresh start.

Form Validation in Flutter. Form plays the most important role for , When text input isn't accepted, an error message can display instructions on how to fix it. Error messages are displayed below the input line, replacing helper� Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! But avoid …. Asking for help, clarification, or responding to other answers.

  • This does indeed solve the problem. Validating the form again resets the error messages for the fields that are now correct.
  • Hi. Thank you. I have followed your advice. But i am not sure how to reset the validation error message in TextFormField. Please help
  • Instead of validating the form again, i just want the textformfield that has error showing to be reset again(clear the error). Is this possible?
  • Yes this is possible . I would suggest for the function validate email to do ur logic and tests . and if there is no problemes return null . and always validate the form field whenever he types something and you should be okay
  • String validateEmail(String value) { if (value.length == 0) { return "too long"; } return null; } TextFormField( validator: validateEmail ),
  • can't we do something like "emailController.validate()" or "emailController.resetError()" instead of validating the entire form?
  • reset method clears all errorneous text fields but only one is changed must be used
  • if you want to clear the error warnings then you have to reset the form validation, I guess for now there is no other way