skip to Main Content

I have a text field with a limited width. I want it to automatically move to the next line when one line is filled. After that, I want to count the number of lines. I am currently using the following method:

String textLine =
    homeController
        .textFieldController
        .text
        .split('n')[index];

However, I must press "Enter" for a new line to be recognized; otherwise, it goes to the next line but does not count it.

Something like this :

enter image description here

2

Answers


  1. use :

    auto_size_text_field: ^2.2.2
    

    AutoSizeTextField(
      controller: _textEditingController,
      style: TextStyle(fontSize: 20),
      maxLines: 2,
    )
    

    Set Max Line based on your screen

    Login or Signup to reply.
  2. I think auto_size_text is what you are looking for.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search