expandSelectionToStart method Null safety

void expandSelectionToStart(
  1. SelectionChangedCause cause

Expand the current selection to the start of the field.

The selection will never shrink. The TextSelection.extentOffset will always be at the start of the field, regardless of the original order of TextSelection.baseOffset and TextSelection.extentOffset.

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

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

See also:


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

  if (selection!.extentOffset == 0) {
  if (!selectionEnabled) {
    return moveSelectionToStart(cause);

  final int lastOffset = math.max(0, math.max(
  final TextSelection nextSelection = TextSelection(
    baseOffset: lastOffset,
    extentOffset: 0,
  _setSelection(nextSelection, cause);