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 width of the render object is the width of one line of text multiplied by this value. In other words, this also controls the width of the actual editing widget.

Implementation

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.

Implementation

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

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