getPositionForPoint method Null safety
- 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();
globalPosition += -_paintOffset;
return _textPainter.getPositionForOffset(globalToLocal(globalPosition));
}