How to expand a textField in flutter looks like a text Area How to expand a textField in flutter looks like a text Area dart dart

How to expand a textField in flutter looks like a text Area


All you need to do is set the maxLines variable when creating a TextField.I have added the text field inside a Card widget so you can see the total area.

@override  Widget build(BuildContext context) {    return Scaffold(      appBar: AppBar(        title: Text("Simple Material App"),      ),      body: Column(        children: <Widget>[          Card(            color: Colors.grey,            child: Padding(              padding: EdgeInsets.all(8.0),              child: TextField(                maxLines: 8,                decoration: InputDecoration.collapsed(hintText: "Enter your text here"),              ),            )          )        ],      )    );  }


Set maxLines to null and keyboardType to TextInputType.multiline like this:

TextField(    maxLines: null,    keyboardType: TextInputType.multiline,) 


Unfortunately, there is no way in flutter you can set the minimum height of a TextField or TextFormField. The best way to give a TextField or a TextFormField a fixed size is to specify the maximum lines the Field should take without expanding farther. Note: This does not limit the amount of input text, it only limits the number of lines shown.

Example:

                             TextFormField(                                keyboardType: TextInputType.multiline,                                maxLines: 8,                                maxLength: 1000,                              ),

This will limit the size of the field to 8 lines, but can take as much as 1000 characters.Hope this will help someone.