getLineAtOffset method

  1. @override
TextSelection getLineAtOffset(
  1. TextPosition position
)
override

Return a TextSelection containing the line of the given TextPosition.

Implementation

@override
TextSelection getLineAtOffset(TextPosition position) {
  final TextRange line = _textPainter.getLineBoundary(position);
  // If text is obscured, the entire string should be treated as one line.
  if (obscureText) {
    return TextSelection(baseOffset: 0, extentOffset: plainText.length);
  }
  return TextSelection(baseOffset: line.start, extentOffset: line.end);
}