startHorizontalCaretMovement method

HorizontalCaretMovementRun startHorizontalCaretMovement(
  1. TextPosition startPosition
)

Starts a HorizontalCaretMovementRun at the given location in the text, for handling consecutive horizontal caret movements.

This can be used to handle consecutive left/right arrow key movements in an input field.

The HorizontalCaretMovementRun.isValid property indicates whether the text layout has changed and the horizontal caret run is invalidated.

The caller should typically discard a HorizontalCaretMovementRun when its HorizontalCaretMovementRun.isValid becomes false, or on other occasions where the horizontal caret run should be interrupted.

Implementation

HorizontalCaretMovementRun startHorizontalCaretMovement(
    TextPosition startPosition) {
  final List<MongolLineMetrics> metrics = _textPainter.computeLineMetrics();
  final MapEntry<int, Offset> currentLine =
      _lineNumberFor(startPosition, metrics);
  return HorizontalCaretMovementRun._(
    this,
    metrics,
    startPosition,
    currentLine.key,
    currentLine.value,
  );
}