getLineBoundary method

  1. @override
TextRange getLineBoundary(
  1. TextPosition position
)
override

Returns the text range of the line at the given offset.

The newline, if any, is included in the range.

The position parameter must be relative to the node's content.

Valid only after layout.

Implementation

@override
TextRange getLineBoundary(TextPosition position) {
  final child = childAtPosition(position);
  final rangeInChild = child.getLineBoundary(TextPosition(
    offset: position.offset - child.container.offset,
    affinity: position.affinity,
  ));
  return TextRange(
    start: rangeInChild.start + child.container.offset,
    end: rangeInChild.end + child.container.offset,
  );
}