Reputation: 2119
I want the text field in flutter to be single line by default. But when user writes a text that does not fit in the single line, I want the text field to become 2 lines, and then 3 lines if 2 lines do not fit. When text does not fit in 3 lines I don't want the number of lines to expand to 4. A similar concept is used in WhatsApp app when writing a message in text field.
TextField(
keyboardType: TextInputType.multiline,
maxLines: 3,
)
Upvotes: 0
Views: 35
Reputation: 7990
Just add minLines=1 in your code,
TextField(
keyboardType: TextInputType.multiline,
maxLines: 3,
minLines: 1,
),
Upvotes: 2