evaluate static method
Evaluates JavaScript code with the given context.
code - JavaScript code to execute
context - Variables to expose to JavaScript
Returns the result of the JavaScript evaluation, or null on error.
Example:
final result = JavaScriptEvaluator.evaluate(
"data.price * data.quantity",
{'data': {'price': 10.0, 'quantity': 5}},
);
print(result); // 50.0
Implementation
static dynamic evaluate(
String code,
Map<String, dynamic> context,
) {
return _instance.evaluate(code, context);
}