getLineBoundary method Null safety

  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.getContainer().offset,
    affinity: position.affinity,
  ));
  return TextRange(
    start: rangeInChild.start + child.getContainer().offset,
    end: rangeInChild.end + child.getContainer().offset,
  );
}