extendSelectionLeft method Null safety

void extendSelectionLeft(
  1. SelectionChangedCause cause
)

Keeping selection's TextSelection.baseOffset fixed, move the TextSelection.extentOffset left.

If selectionEnabled is false, keeps the selection collapsed and moves it left.

The given SelectionChangedCause indicates the cause of this change and will be passed to onSelectionChanged.

See also:

Implementation

void extendSelectionLeft(SelectionChangedCause cause) {
  assert(selection != null);

  if (!selectionEnabled) {
    return moveSelectionLeft(cause);
  }

  final TextSelection nextSelection = _extendGivenSelectionLeft(
    selection!,
    _plainText,
  );
  if (nextSelection == selection) {
    return;
  }
  final int distance = selection!.extentOffset - nextSelection.extentOffset;
  _cursorResetLocation -= distance;
  _setSelection(nextSelection, cause);
}