getLineAtOffset method
Return a TextSelection containing the line of the given TextPosition.
Implementation
@override
TextSelection getLineAtOffset(TextPosition position) {
final child = childAtPosition(position);
final nodeOffset = child.container.offset;
final localPosition = TextPosition(offset: position.offset - nodeOffset, affinity: position.affinity);
final localLineRange = child.getLineBoundary(localPosition);
final line = TextRange(
start: localLineRange.start + nodeOffset,
end: localLineRange.end + nodeOffset,
);
return TextSelection(baseOffset: line.start, extentOffset: line.end);
}