getPositionForPoint method
- Offset globalPosition
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) {
_computeTextMetricsIfNeeded();
return _textPainter.getPositionForOffset(globalToLocal(globalPosition) - _paintOffset);
}