getLocalRectForCaret method

Rect getLocalRectForCaret (TextPosition caretPosition)

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

See also:

Implementation

Rect getLocalRectForCaret(TextPosition caretPosition) {
  _layoutText(constraints.maxWidth);
  final Offset caretOffset = _textPainter.getOffsetForCaret(caretPosition, _caretPrototype);
  // This rect is the same as _caretPrototype but without the vertical padding.
  return Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight).shift(caretOffset + _paintOffset);
}