We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 94d277a + c0206e7 commit dfc5b62Copy full SHA for dfc5b62
lib/src/form_builder.dart
@@ -257,11 +257,13 @@ class FormBuilderState extends State<FormBuilder> {
257
if (hasError) {
258
final wrongFields =
259
fields.values.where((element) => element.hasError).toList();
260
- if (focusOnInvalid) {
261
- wrongFields.first.focus();
262
- }
263
- if (autoScrollWhenFocusOnInvalid) {
264
- wrongFields.first.ensureScrollableVisibility();
+ if (wrongFields.isNotEmpty) {
+ if (focusOnInvalid) {
+ wrongFields.first.focus();
+ }
+ if (autoScrollWhenFocusOnInvalid) {
265
+ wrongFields.first.ensureScrollableVisibility();
266
267
}
268
269
return !hasError;
0 commit comments