Create Multiline TextField In Flutter

In this snippet, we will look at creating a multiline text field in Flutter. A multiline Textfield is a text field widget that allows the user to input multiple lines of text.

To create a multiline text field, use the TextField widget. The TextField widget has a maxLines property that allows you to specify the maximum number of lines the Textfield can have.

    maxLines: 5
//allow the field to incease height if input text exceeds maxLines
    maxLines: 3
    expands: true, 
//set fixed height for text field with minLines
    controller: _controller,
    minLines: 3,
    maxLines: 5,
    decoration: const InputDecoration(label: Text("URLs")),
//add ellipsis if text exceeds the field's height
Text('line 1\nline 2\nline 3\nline 4\nline 5', maxLines: 4,
       overflow: TextOverflow.ellipsis,
       textDirection: TextDirection.rtl,
       textAlign: TextAlign.justify,

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.