Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Automatically resize Flutter TextFormField content as the user is typing while keeping maxLines equal to 1

I am using TextFormField in my Flutter app to get the email address of users. Some email addresses are long and so, if I keep typing, it will go out of the box. See how the first few letters of the email in the image below are outside the box.

enter image description here

Below is the code (just a simple TextFormField). I want the text to automatically resize while remaining in one line and also I can see all the text. Is there a way to do that?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

SizedBox(
    width: ScreenUtil().setWidth(407),
    height: ScreenUtil().setHeight(69),
    child: TextFormField(
      textAlign: TextAlign.center,
      autocorrect: false,
      textCapitalization: TextCapitalization.none,
      keyboardType: TextInputType.emailAddress,
    )
)

>Solution :

Use auto_size_text_field package

AutoSizeTextField(
  controller: _textEditingController,
  style: TextStyle(fontSize: 20),
  maxLines: 1,
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading