1

I have a problem. I create a TextFormField. When text length is so lengthy, I want textField will display as the below image. Help me. Thank you.

enter image description here

This is code:

TextFormField(
            controller: nameController,
            enabled: false,
            textInputAction: TextInputAction.next,
            keyboardType: TextInputType.emailAddress,
            style: TextUtil.regularArial.copyWith(
              fontSize: ScreenUtil.getInstance().setSp(14),
              color: ColorUtil.grey8E8E8E,
            ),
            decoration: InputDecoration(
              fillColor: Colors.white,
              filled: true,
              isDense: true,
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.circular(6)),
                borderSide: BorderSide(color: Colors.white, width: 1),
              ),
              hintText: "Email",
              hintStyle: TextUtil.regularArial.copyWith(
                fontSize: ScreenUtil.getInstance().setSp(14),
                color: ColorUtil.grey7A7A7A,
              ),
            ),
            validator: (value){
             
            },
          ),
Chung
  • 146
  • 10

1 Answers1

1

Try add maxLines: null

TextFormField(maxLines: null)

If the maxLines property is null, there is no limit to the number of lines, and the wrap is enabled.

Aldy Yuan
  • 1,795
  • 9
  • 23
  • I used maxLines: null but it only expand height TextField – Chung Jun 21 '20 at 05:44
  • I want to display TextFormField on only one line – Chung Jun 21 '20 at 05:45
  • I'm sorry I don't know the answer, and why would you do that anyway someone input their email address and they can't see the rest of the email. But if you trying to do it with Text you can try adding TextOverflow.ellipsis `Text("Very Long Text", overflow: TextOverflow.ellipsis)` it will work like charm – Aldy Yuan Jun 21 '20 at 12:14
  • No matter, Thank for your helping. – Chung Jun 21 '20 at 12:45