Skip to content

Commit 8752612

Browse files
committed
Fix
1 parent bae020e commit 8752612

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/src/form_builder_validators.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -622,17 +622,20 @@ class FormBuilderValidators {
622622
String? errorText,
623623
}) {
624624
return (T? valueCandidate) {
625-
assert(valueCandidate is num || valueCandidate is String);
626-
final number = valueCandidate is num
627-
? valueCandidate
628-
: num.tryParse(valueCandidate.toString());
625+
if (valueCandidate != null) {
626+
assert(valueCandidate is num || valueCandidate is String);
627+
final number = valueCandidate is num
628+
? valueCandidate
629+
: num.tryParse(valueCandidate.toString());
629630

630-
final minResult =
631-
min(minValue, inclusive: inclusive, errorText: errorText)(number);
632-
final maxResult =
633-
max(maxValue, inclusive: inclusive, errorText: errorText)(number);
631+
final minResult =
632+
min(minValue, inclusive: inclusive, errorText: errorText)(number);
633+
final maxResult =
634+
max(maxValue, inclusive: inclusive, errorText: errorText)(number);
634635

635-
return errorText ?? minResult ?? maxResult;
636+
return errorText ?? minResult ?? maxResult;
637+
}
638+
return null;
636639
};
637640
}
638641

0 commit comments

Comments
 (0)