getOffsetForCaret method Null safety

  1. @override
Offset getOffsetForCaret(
  1. TextPosition position

Returns the offset at which to paint the caret.

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

Valid only after layout.


Offset getOffsetForCaret(TextPosition position) {
  final child = childAtPosition(position);
  return child.getOffsetForCaret(TextPosition(
        offset: position.offset - child.getContainer().offset,
        affinity: position.affinity,
      )) +
      (child.parentData as BoxParentData).offset;