extendSelectionRight method Null safety

void extendSelectionRight(
  1. SelectionChangedCause cause
)

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

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

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

See also:

Implementation

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

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

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