pressLetfArrowKey method

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

Moves the cursor one character to the left.

If isShiftPressed is true, extends the selection.

Implementation

void pressLetfArrowKey({bool isShiftPressed = false}) {
  int newOffset;
  if (!isShiftPressed && selection.start != selection.end) {
    newOffset = selection.start;
  } else if (selection.extentOffset > 0) {
    newOffset = selection.extentOffset - 1;
  } else {
    newOffset = 0;
  }

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