backspace method

bool backspace()

Deletes the character before the cursor (backspace).

Returns true if a character was deleted.

Implementation

bool backspace() {
  if (_cursorPosition == 0) return false;

  final before = text.substring(0, _cursorPosition - 1);
  final after = text.substring(_cursorPosition);

  _buffer.clear();
  _buffer.write(before);
  _buffer.write(after);

  _cursorPosition--;
  return true;
}