getImePreeditCaretScreenRect method

Rect? getImePreeditCaretScreenRect(
  1. int caretOffsetInPreedit
)

Returns the caret Rect (global screen coords) for a caret sitting caretOffsetInPreedit characters into the active IME preedit. The preedit is injected into _painter but not into _fragmentPositions, so the painter offset is the preedit-start global offset plus the in-preedit caret offset. Lets the candidate window follow the caret.

Implementation

Rect? getImePreeditCaretScreenRect(int caretOffsetInPreedit) {
  if (_imePreeditFragmentId.isEmpty) return null;
  final base = _localToGlobal(_imePreeditFragmentId, _imePreeditLocalOffset);
  if (base == null) return null;
  return _screenRectForPainterOffset(base + caretOffsetInPreedit);
}