getPositionForOffset method

TextPosition getPositionForOffset(
  1. Offset offset
)

Returns the position within the text for the given pixel offset.

Implementation

TextPosition getPositionForOffset(Offset offset) {
  assert(_debugAssertTextLayoutIsValid);
  assert(!_debugNeedsRelayout);
  final _TextPainterLayoutCacheWithOffset cachedLayout = _layoutCache!;
  return cachedLayout.paragraph
      .getPositionForOffset(offset - cachedLayout.paintOffset);
}