Returns the Rect in local coordinates for the caret at the given text position.
Source
Rect getLocalRectForCaret(TextPosition caretPosition) {
Offset caretOffset = _textPainter.getOffsetForCaret(caretPosition, _caretPrototype);
// This rect is the same as _caretPrototype but without the vertical padding.
return new Rect.fromLTWH(0.0, 0.0, _kCaretWidth, _preferredLineHeight).shift(caretOffset + _paintOffset);
}