getLineBoundary method

TextRange getLineBoundary (TextPosition position)

Returns the TextRange of the line at the given TextPosition.

The newline (if any) is returned as part of the range.

Not valid until after layout.

This can potentially be expensive, since it needs to compute the line metrics, so use it sparingly.

Implementation

TextRange getLineBoundary(TextPosition position) {
  final List<int> boundary = _getLineBoundary(position.offset);
  return TextRange(start: boundary[0], end: boundary[1]);
}