delete method

void delete()

Delete one character after the cursor (Delete behavior)

Implementation

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

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

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