File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -300,6 +300,11 @@ class CupertinoTextField extends StatefulWidget {
300
300
assert (clearButtonMode != null ),
301
301
assert (prefixMode != null ),
302
302
assert (suffixMode != null ),
303
+ // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
304
+ assert (! identical (textInputAction, TextInputAction .newline) ||
305
+ maxLines == 1 ||
306
+ ! identical (keyboardType, TextInputType .text),
307
+ 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.' ),
303
308
keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType .text : TextInputType .multiline),
304
309
toolbarOptions = toolbarOptions ?? (obscureText ?
305
310
const ToolbarOptions (
Original file line number Diff line number Diff line change @@ -376,6 +376,11 @@ class TextField extends StatefulWidget {
376
376
),
377
377
assert (! obscureText || maxLines == 1 , 'Obscured fields cannot be multiline.' ),
378
378
assert (maxLength == null || maxLength == TextField .noMaxLength || maxLength > 0 ),
379
+ // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
380
+ assert (! identical (textInputAction, TextInputAction .newline) ||
381
+ maxLines == 1 ||
382
+ ! identical (keyboardType, TextInputType .text),
383
+ 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.' ),
379
384
keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType .text : TextInputType .multiline),
380
385
toolbarOptions = toolbarOptions ?? (obscureText ?
381
386
const ToolbarOptions (
You can’t perform that action at this time.
0 commit comments