Methods
-
addInterface(String funcName, dynamic func(dynamic args))
→ bool
-
在 JSContext 中添加一个 dart bridge 函数
func 支持异步函数, 对应 js 中返回 promise
-
dynamicToJSFValue(dynamic v)
→ JSFValue
-
将 dart 中的值转为 js 中的值
当前支持 Null、num、String、bool 类型
其他类型会被转为 String 类型
-
eval(String script, {JSFValue? thiz, String? sourceURL, int startingLineNumber = 1})
→ JSFValue
-
执行 js 代码
-
evalAsync(String script, {JSFValue? thiz, String? sourceURL, int startingLineNumber = 1, Duration timeout = const Duration(seconds: 16)})
→ Future<JSFValue>
-
执行 js 代码,如果返回值是 promise,则返回一个 future
如果返回值不是 promise,则直接返回 future.value(返回值)
-
evalIsolate(String script, {JSFValue? thiz, String? sourceURL, int startingLineNumber = 1})
→ Future<JSFValue?>
-
在新的 isolate 中执行 js 代码
-
free()
→ void
-
释放 JSContext
-
loadExtension({bool console = true, bool xhr = true, bool fetch = true, bool timeout = true, bool interval = true, bool promise = true})
→ JSFExtension?
-
加载扩展
默认加载 console, xhr, fetch, timeout, interval, promise 扩展
如果需要加载其他扩展,请使用 context.extension?.chain(XXXExtension(context))
-
makeBoolean(bool v)
→ JSFValue
-
在 dart 中创建一个 js 的 Boolean 对象
-
makeError(String errorStr)
→ JSFValue
-
在 dart 中创建一个 js 的 Error 对象
-
makeJsonString(String jsonStr)
→ JSFValue
-
在 dart 中创建一个 js 的 JSON 对象
-
makeNull()
→ JSFValue
-
在 dart 中创建一个 js 的 undefined 对象
-
makeNumber(int number)
→ JSFValue
-
在 dart 中创建一个 js 的 Number 对象
-
makeString(String str)
→ JSFValue
-
在 dart 中创建一个 js 的 String 对象
-
makeUndefined()
→ JSFValue
-
在 dart 中创建一个 js 的 undefined 对象
-
nativeFutureToPromise(Future fut)
→ JSFValue?
-
将 dart 中的 Future 转为 js 中的 promise
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
removeInterface(String funcName)
→ bool
-
移除 JSContext 中添加的 dart bridge 函数
-
runPromise(JSFValue promise, {Duration timeout = const Duration(days: 1)})
→ Future<JSFValue>
-
手动执行一个 js promise 函数,返回 future
-
toString()
→ String
-
A string representation of this object.
inherited