Skip to content

Commit 162fce8

Browse files
authored
Made maxLines property nullable and added assertions (#810)
* Made maxLines property nullable and added assertions maxLines must be nullable to be able to expand vertically on user input it also needs to be nullable to use the expands property without errors * Fixed error cause by null operator
1 parent 145bd1f commit 162fce8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/src/fields/form_builder_text_field.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class FormBuilderTextField extends FormBuilderField<String> {
6868
final bool enableSuggestions;
6969

7070
/// {@macro flutter.widgets.editableText.maxLines}
71-
final int maxLines;
71+
final int? maxLines;
7272

7373
/// {@macro flutter.widgets.editableText.minLines}
7474
final int? minLines;
@@ -343,12 +343,13 @@ class FormBuilderTextField extends FormBuilderField<String> {
343343
this.mouseCursor,
344344
}) : assert(initialValue == null || controller == null),
345345
assert(minLines == null || minLines > 0),
346+
assert(maxLines == null || maxLines > 0),
346347
assert(
347-
(minLines == null) || (maxLines >= minLines),
348+
(minLines == null) || (maxLines == null) || (maxLines >= minLines),
348349
'minLines can\'t be greater than maxLines',
349350
),
350351
assert(
351-
!expands || (minLines == null),
352+
!expands || (minLines == null && maxLines == null),
352353
'minLines and maxLines must be null when expands is true.',
353354
),
354355
assert(!obscureText || maxLines == 1,

0 commit comments

Comments
 (0)