backspace method

void backspace()

Delete one character before the cursor (Backspace behavior)

Implementation

void backspace() {
  if (!_selection.isCollapsed) {
    _deleteSelectionInternal();
    notifyListeners();
    return;
  }

  final offset = _selection.baseOffset;
  if (offset > 0) {
    final before = _text.substring(0, offset - 1);
    final after = _text.substring(offset);
    _text = before + after;

    _selection = TextSelection.collapsed(offset: offset - 1);
    _reparse();
    notifyListeners();
  }
}