getPositionForOffset method Null safety

TextPosition getPositionForOffset(
  1. Offset offset
)

Returns the text position closest to the given offset.

Implementation

TextPosition getPositionForOffset(Offset offset) {
  final List<int> encoded = _getPositionForOffset(offset.dx, offset.dy);
  return TextPosition(offset: encoded[0], affinity: TextAffinity.values[encoded[1]]);
}