calculator static method
Implementation
static num calculator(num operand1, String operators, num operand2) {
try {
if (operators == '' || operand1.isNaN == true || operand2.isNaN == true) {
throw Exception('Operator null or error input');
}
if (operators == '+') return operand1 + operand2;
if (operators == '-') return operand1 - operand2;
if (operators == '/') return operand1 / operand2;
if (operators == '*') return operand1 * operand2;
} on Exception catch (exception) {
print(exception.toString());
}
return 0;
}