performOperation method

dynamic performOperation(
  1. dynamic nextOperator
)

Implementation

performOperation(nextOperator) {
  var inputValue = double.parse(displayValue.replaceAll(",", ""));

  if (value == null) {
    this.setState(() {
      value = inputValue;
    });
  } else if (operator != null) {
    var currentValue = value ?? 0;
    var newValue = calculatorOperations[operator]!(currentValue, inputValue);

    this.setState(() {
      value = newValue;
      displayValue = formatter.format(newValue).toString();
    });
  }

  this.setState(() {
    waitingForOperand = true;
    operator = nextOperator;
  });
}