-
-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FormBuilderField]: Add "resetError" method #1390
Labels
awaiting author response
Waiting for author of issue to respond with more info
enhancement
New feature or request
Comments
Hey @dimzeta, |
The only thing I found that clear the |
Hi @dimzeta @Ez3kiel-dev and @uzuki-P import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter FormBuilder Example',
debugShowCheckedModeBanner: false,
localizationsDelegates: const [
FormBuilderLocalizations.delegate,
...GlobalMaterialLocalizations.delegates,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: FormBuilderLocalizations.supportedLocales,
home: const _ExamplePage(),
);
}
}
class _ExamplePage extends StatefulWidget {
const _ExamplePage();
@override
State<_ExamplePage> createState() => _ExamplePageState();
}
class _ExamplePageState extends State<_ExamplePage> {
final _formKey = GlobalKey<FormBuilderState>();
AutovalidateMode _autovalidateMode = AutovalidateMode.disabled;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Minimal code example')),
body: Padding(
padding: const EdgeInsets.all(16),
child: FormBuilder(
key: _formKey,
autovalidateMode: _autovalidateMode,
child: Column(
children: [
FormBuilderTextField(
name: 'email',
autofillHints: const [
AutofillHints.email,
],
keyboardType: TextInputType.emailAddress,
validator: FormBuilderValidators.compose([
FormBuilderValidators.required(),
FormBuilderValidators.email(),
]),
),
const SizedBox(height: 10),
ElevatedButton(
onPressed: () {
// When the form is submitted and is invalid, the autovalidate mode is set to always
// so then the user can see the errors and the form will be validated on every change
if (!_formKey.currentState!.saveAndValidate() &&
_autovalidateMode != AutovalidateMode.always) {
setState(() {
_autovalidateMode = AutovalidateMode.always;
});
}
},
child: Text('Submit'),
),
],
),
),
),
);
}
}
|
deandreamatias
added
the
awaiting author response
Waiting for author of issue to respond with more info
label
Jan 8, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
awaiting author response
Waiting for author of issue to respond with more info
enhancement
New feature or request
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:
Alternatives you've considered
No response
Aditional information
No response
The text was updated successfully, but these errors were encountered: