Flutter logo

Flutter: expand TextField height to match parent widget

Written by

in

In Flutter, the TextField widget shows a single line by default. To expand the height of TextField to match the parents widgets height, the following code can be used:

Dart
Container(
  height: 500.0,
  child: TextField(
    expands: true,
    minLines: null,
    maxLines: null,
    ...
  ),
),

The important thing is, that both minLines and maxLines need to be set to null.

To set the height of the Container to match it’s parent or even the complete screen, height can be set to double.infinity.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *