maxLines property
The maximum number of lines to show at one time, wrapping if necessary.
This affects the height of the field itself and does not limit the number of lines that can be entered into the field.
If this is 1 (the default), the text will not wrap, but will scroll horizontally instead.
If this is null, there is no limit to the number of lines, and the text container will start with enough vertical space for one line and automatically grow to accommodate additional lines as they are entered, up to the height of its constraints.
If this is not null, the value must be greater than zero, and it will lock the input to the given number of lines and take up enough horizontal space to accommodate that number of lines. Setting minLines as well allows the input to grow and shrink between the indicated range.
The full set of behaviors possible with minLines and maxLines are as follows. These examples apply equally to TextField, TextFormField, CupertinoTextField, and EditableText.
Input that occupies a single line and scrolls horizontally as needed.
const TextField()
Input whose height grows from one line up to as many lines as needed for the text that was entered. If a height limit is imposed by its parent, it will scroll vertically when its height reaches that limit.
const TextField(maxLines: null)
The input's height is large enough for the given number of lines. If additional lines are entered the input scrolls vertically.
const TextField(maxLines: 2)
Input whose height grows with content between a min and max. An infinite max is possible with maxLines: null
.
const TextField(minLines: 2, maxLines: 4)
See also:
Implementation
final int? maxLines;