Skip to content

Commit 4a9ea71

Browse files
committed
feat: rename validationAutoFocus to autoFocusOnValidationFailure - clearer
1 parent b70bf6d commit 4a9ea71

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/src/form_builder.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class FormBuilder extends StatefulWidget {
5959
final bool enabled;
6060

6161
/// Whether the form should auto focus on the first field that fails validation.
62-
final bool validationAutoFocus;
62+
final bool autoFocusOnValidationFailure;
6363

6464
/// Creates a container for form fields.
6565
///
@@ -73,7 +73,7 @@ class FormBuilder extends StatefulWidget {
7373
this.initialValue = const <String, dynamic>{},
7474
this.skipDisabled = false,
7575
this.enabled = true,
76-
this.validationAutoFocus = true,
76+
this.autoFocusOnValidationFailure = false,
7777
}) : super(key: key);
7878

7979
static FormBuilderState? of(BuildContext context) =>
@@ -115,7 +115,7 @@ class FormBuilderState extends State<FormBuilder> {
115115
// assistance to accidental duplicate names, we check and emit a warning.
116116
assert(() {
117117
if (_fields.containsKey(name)) {
118-
print('Warning! Replacing duplicate Field for $name'
118+
debugPrint('Warning! Replacing duplicate Field for $name'
119119
' -- this is OK to ignore as long as the field was intentionally replaced');
120120
}
121121
return true;
@@ -135,7 +135,7 @@ class FormBuilderState extends State<FormBuilder> {
135135
assert(() {
136136
// This is OK to ignore when you are intentionally replacing a field
137137
// with another field using the same name.
138-
print('Warning! Ignoring Field unregistration for $name'
138+
debugPrint('Warning! Ignoring Field unregistration for $name'
139139
' -- this is OK to ignore as long as the field was intentionally replaced');
140140
return true;
141141
}());
@@ -156,7 +156,7 @@ class FormBuilderState extends State<FormBuilder> {
156156

157157
bool validate() {
158158
final hasError = !_formKey.currentState!.validate();
159-
if (hasError && widget.validationAutoFocus) {
159+
if (hasError && widget.autoFocusOnValidationFailure) {
160160
final wrongFields =
161161
fields.values.where((element) => element.hasError).toList();
162162
wrongFields.first.requestFocus();

0 commit comments

Comments
 (0)