skip to Main Content
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


  1. The error you’re encountering is due to the combination of the obscureText property set to true and the maxLines property set to a value greater than 1. The obscureText 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:

    1. Set obscureText to false 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.

    2. Set maxLines to 1 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'

    • "Obscured fields cannot be multiline" indicates that the combination of obscureText being true and maxLines being greater than 1 is not allowed.
    • "Failed assertion: line 171 pos 15: ‘!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 either obscureText should be false or maxLines should be 1.

    I hope this helps!

    Login or Signup to reply.
  2. Ok try this code:

    TextFormField(
          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,
            ),
          ),
        ),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search