flutter-form-builder-ecosystem / flutter_form_builder

Simple form maker for Flutter Framework
https://pub.dev/packages/flutter_form_builder
MIT License
1.48k stars 535 forks source link

[FormBuilderField]: Add "resetError" method #1390

Open dimzeta opened 5 months ago

dimzeta commented 5 months ago

Is there an existing issue for this?

Package/Plugin version

9.2.1

What you'd like to happen

The form is validated only when the user click on submit. At this moment, some fields are invalidate, with an error message.

I would like on remove the error message as soon as the user updates the value.

Example:

FormBuilder(
  key: _formKey,
  autovalidateMode: AutovalidateMode.disabled,
  child: Column(
    children: [
      FormBuilderTextField(
        name: 'email',
        autofillHints: const [
          AutofillHints.email,
        ],
        keyboardType: TextInputType.emailAddress,
        // * reset field error when value changes
        // * using Form Key
        onChanged: (value) => _formKey.currentState?.fields['email']?.resetError(),
        // * OR using Field Key
        onChanged: (value) => _fieldKey.currentState?.resetError(),
        validator: FormBuilderValidators.compose([
          FormBuilderValidators.required(),
          FormBuilderValidators.email(),
        ]),
      ),
    ],
  ),
);

Alternatives you've considered

No response

Aditional information

No response

Ez3kiel-dev commented 1 month ago

Hey @dimzeta, I was also looking for the same thing. Did you find a workaround for this ?

uzuki-P commented 2 days ago

The only thing I found that clear the _customErrorText was this validate function.