TextFormField(
keyboardType: TextInputType.multiline,
maxLines: 4,
decoration: InputDecoration(
filled: true,
fillColor: AppColors.ARGB.withOpacity(0.3),
isDense: true,
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
width: 1,
)),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(
DimensionsResource.RADIUS_EXTRA_SMALL),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.only(
top: 16, bottom: 16, left: 10),
hintText: 'Enter Detected Box IDs',
hintStyle: const TextStyle(
color: AppColors.WHITE,
fontSize: DimensionsResource.FONT_SIZE_SMALL_2X,
fontWeight: FontWeight.w200,
),
),
),
Obscured fields cannot be multiline. Failed assertion: line 171 pos
15: ‘!obscureText || maxLines == 1’
getting this error
2
Answers
The error you’re encountering is due to the combination of the
obscureText
property set totrue
and themaxLines
property set to a value greater than1
. TheobscureText
property is used to hide the text input as it is being typed, and it is not compatible with multiline text fields.To resolve this error, you have two options:
Set
obscureText
tofalse
if you want a multiline text field. This will allow users to see the text as they type it, but it will not be hidden.Set
maxLines
to1
if you want to keep the text field obscured. This will prevent users from entering multiple lines of text, but it will also keep the text hidden.Here’s a breakdown of the error message:
Obscured fields cannot be multiline. Failed assertion: line 171 pos 15:
'!obscureText || maxLines == 1'
obscureText
beingtrue
andmaxLines
being greater than1
is not allowed.!obscureText || maxLines == 1
‘" refers to the specific line of code (line 171) where the assertion is failing. The assertion checks whether!obscureText || maxLines == 1
, which means that eitherobscureText
should befalse
or maxLines should be1
.I hope this helps!
Ok try this code: