pressEndKey method

void pressEndKey({
  1. bool isShiftPressed = false,
})

Moves the cursor to the end of the current line.

If isShiftPressed is true, extends the selection to the line end.

Implementation

void pressEndKey({bool isShiftPressed = false}) {
  final currentLine = getLineAtOffset(selection.extentOffset);
  final lineText = getLineText(currentLine);
  final lineStart = getLineStartOffset(currentLine);
  final lineEnd = lineStart + lineText.length;

  if (isShiftPressed) {
    setSelectionSilently(
      TextSelection(baseOffset: selection.baseOffset, extentOffset: lineEnd),
    );
  } else {
    setSelectionSilently(TextSelection.collapsed(offset: lineEnd));
  }
}