evalRaw method

Future<String> evalRaw(
  1. String code, {
  2. Duration? timeout,
  3. String name = '<eval>',
  4. Map<String, Object?> tempGlobals = const {},
})

在当前 runtime 中执行 code

调用只会入队,不会在 Flutter UI isolate 中同步执行 JS。 tempGlobals 会在本次执行期间临时注入到 JS globalThis,执行结束后恢复。 Returns QuickJS's raw bridge string without Dart value conversion. Prefer eval unless the exact textual representation is required.

Implementation

Future<String> evalRaw(
  String code, {

  /// 从任务入队开始计算的总时限,包含排队和 JavaScript 执行时间。
  Duration? timeout,

  /// 本次执行的源码名称,用于错误堆栈、诊断信息和 source map 匹配。
  String name = '<eval>',
  Map<String, Object?> tempGlobals = const {},
}) {
  final validName = _validateSourceName(name);
  return _enqueue(
    _wrapWithTempGlobals(code, tempGlobals, name: validName),
    timeout: timeout,
    name: validName,
  );
}