evaluate method
Evaluates the mathematical expression
and returns the result. This method
should be used to evaluate those expression that don't contain the x
variable. For example:
"6 + 10 * 3 / 7"
// Good"6 + 10 * x / 7"
// Bad
If you want to evaluate a function with the x
variable, use evaluateOn.
Implementation
double evaluate(String expression) {
if (expression.contains('x') || (!_parser.accept(expression))) {
throw const ExpressionParserException('The given expression cannot be '
'parsed! Make sure that all operators are supported. Make also sure '
"that the product of two values explicitly has the '*' symbol.\n\n "
"There cannot be the 'x' variable in the expression because this "
'method only evaluates numbers.');
}
return evaluateOn(expression, 0);
}