updateSelection method

void updateSelection(
  1. TextRange? range
)

Set the selection

Implementation

void updateSelection(TextRange? range) {
  if (range != null) {
    final start = range.start.clamp(0, _text.length);
    final end = range.end.clamp(0, _text.length);
    if (start <= end) {
      _selection = TextRange(start: start, end: end);
    } else {
      _selection = null;
    }
  } else {
    _selection = null;
  }
  notifyListeners();
}