getCaretPosition function

Offset getCaretPosition(
  1. RenderObject box
)

Implementation

Offset getCaretPosition(RenderObject box) {
  final RenderEditable renderEditable = findRenderEditable(box);
  if (!renderEditable.hasFocus) {
    return const Offset(0, 0);
  }
  final List<TextSelectionPoint> endpoints = globalize(
    renderEditable.getEndpointsForSelection(renderEditable.selection!),
    renderEditable,
  );
  return endpoints[0].point + const Offset(0.0, -2.0);
}