getPositionForPoint method
Returns the position in the text for the given global coordinate.
See also:
- getLocalRectForCaret, which is the reverse operation, taking a TextPosition and returning a Rect.
- TextPainter.getPositionForOffset, which is the equivalent method for a TextPainter object.
Implementation
TextPosition getPositionForPoint(Offset globalPosition) {
_layoutText(constraints.maxWidth);
globalPosition += -_paintOffset;
return _textPainter.getPositionForOffset(globalToLocal(globalPosition));
}