maxLines property

int? maxLines

The maximum number of lines for the text to span, wrapping if necessary.

If this is 1 (the default), the text will not wrap, but will extend indefinitely instead.

If this is null, there is no limit to the number of lines.

When this is not null, the intrinsic height of the render object is the height of one line of text multiplied by this value. In other words, this also controls the height of the actual editing widget.


int? get maxLines => _maxLines;
void maxLines=(int? value)

The value may be null. If it is not null, then it must be greater than zero.


set maxLines(int? value) {
  assert(value == null || value > 0);
  if (maxLines == value) {
  _maxLines = value;

  // Special case maxLines == 1 to keep only the first line so we can get the
  // height of the first line in case there are hard line breaks in the text.
  // See the `_preferredHeight` method.
  _textPainter.maxLines = value == 1 ? 1 : null;