handleBackspace method Null safety

  1. @override
void handleBackspace()
override

Implementation

@override
void handleBackspace() {
  final int? ex = _exponent;
  if (ex != null) {
    int? newEx;
    bool newNeg;
    if (ex == 0) {
      if (_negativeExponent) {
        newNeg = false;
        newEx = 0;
      } else {
        newNeg = false;
        newEx = null;
      }
    } else {
      newEx = ex ~/ 10;
      newNeg = _negativeExponent;
    }
    _tryNewValue(_entered, _sign, newEx, newNeg);
  } else if (_entered.length > 1) {
    if (_sign == '-') {
      _tryNewValue(_entered, '', ex, _negativeExponent);
    } else {
      _tryNewValue(_entered.substring(0, _entered.length - 1), _sign, ex,
          _negativeExponent);
    }
  } else {
    changeState(Resting(controller)).handleBackspace();
  }
}