getLineAtOffset method

  1. @override
TextSelection getLineAtOffset(
  1. TextPosition position

Return a TextSelection containing the line of the given TextPosition.


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);