evaluate static method
Evaluates JavaScript code with the given context.
code - JavaScript code to execute
context - Variables to expose to JavaScript
timeoutMs - Maximum execution time in milliseconds (default: 5000)
Returns the result of the JavaScript evaluation, or null on error.
Example:
final result = JavaScriptEvaluator.evaluate(
"input === 'magic'",
{'input': 'magic'},
);
print(result); // true
Implementation
static dynamic evaluate(
String code,
Map<String, dynamic> context, {
int timeoutMs = 5000,
}) {
return evaluateJS(code, context, timeoutMs: timeoutMs);
}