TextPosition getPositionForPoint(Point globalPosition)

Returns the position in the text for the given global coordinate.

Source

TextPosition getPositionForPoint(Point globalPosition) {
  globalPosition += -paintOffset;
  return _textPainter.getPositionForOffset(globalToLocal(globalPosition).toOffset());
}