getBeginningPositionNearX method

  1. @override
TextNodePosition getBeginningPositionNearX(
  1. double x
)
override

Returns the earliest position within this component's DocumentNode that appears at or near the given x position.

This is useful, for example, when moving selection into the beginning of some text while maintaining the existing horizontal position of the selection.

Implementation

@override
TextNodePosition getBeginningPositionNearX(double x) {
  return TextNodePosition.fromTextPosition(
    textLayout.getPositionInFirstLineAtX(x),
  );
}