getLocalRectForCaret method

Rect getLocalRectForCaret (TextPosition caretPosition)

Returns the Rect in local coordinates for the caret at the given text position.

See also:


Rect getLocalRectForCaret(TextPosition caretPosition) {
  final Offset caretOffset = _textPainter.getOffsetForCaret(caretPosition, _caretPrototype);
  // This rect is the same as _caretPrototype but without the vertical padding.
  Rect rect = Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight).shift(caretOffset + _paintOffset);
  // Add additional cursor offset (generally only if on iOS).
  if (_cursorOffset != null)
    rect = rect.shift(_cursorOffset);

  return rect.shift(_getPixelPerfectCursorOffset(rect));