How to increase the length of a TextField while pressing "Enter" in Flutter?

Viewed 44

I have a textfield of maxLength set to 150. However, I want to textField's maxLine property to increase by 1 as I press enter. How can I achieve this please?

Find my code below:

child: Padding(
                      padding: const EdgeInsets.all(20.0),
                      child: TextField(
                        maxLines: 5,
                        maxLength: 150,
                        controller: _userAboutController,
                        decoration: InputDecoration(
                          helperText: '(Optional)',
                          labelText: user.about,
                          icon: Image.asset(
                            "Assets/images/country.png",
                            height: 40.0,
                          ),
                          focusedBorder: UnderlineInputBorder(
                            borderSide:
                            BorderSide(color: secondaryColor, width: 2.0),
                          ),
                      ),
                    ),
                  ),
1 Answers
  1. Declare int maxLines = 5

  2. When enter pressed, add increment for maxLines.

    maxLines ++;

  3. Finally change textField

    maxLines: 5 to maxLines ;

Related