dart:js_util_wasm library Null safety


JSValue is the root of the JS interop object hierarchy.


Conversion functions. TODO(joshualitt): Only a small set of types currently work: JS -> Dart: null strings arrays opaque Dart objects passed to JS Dart -> JS: null boolean doubles strings lists opaque JS objects passed to Dart In the future we would like to support more types, at least maps, and to fix some of the issues returning some types from JS. Extension methods for conversions.


callConstructorVarArgs(JSValue o, String name, List<JSValue?> args) JSValue
Gets a String name property off of a JS object o, invokes it as a constructor with a JS array of arguments args, and returns the constructed JS object.
callConstructorVarArgsRaw(dynamic o, dynamic name, dynamic args) → dynamic
callMethodVarArgs(JSValue o, String method, List<JSValue?> args) JSValue?
Calls a JS method with a String name on JS object o with a JS array of arguments args and returns the resulting JS value.
callMethodVarArgsRaw(dynamic o, dynamic method, dynamic args) → dynamic
dartify(JSValue? object) Object?
Recursively converts objects from JS to Dart.
dartifyRaw(dynamic object) → dynamic
eval(String code) → void
js util methods. These are low level calls into JS, and require care to use correctly. Evals a snippet of JS code in a Dart string.
evalRaw(dynamic code) → void
Raw public JS functions. These are public temporarily to give performance conscious users an escape hatch while we decide what this API will actually look like. They may become private in the future, or disappear entirely. For descriptions of the API, please see the corresponding non-raw functions.
getProperty(JSValue o, String name) JSValue?
Gets a JS property with String name off of a JS object o.
getPropertyRaw(dynamic o, dynamic name) → dynamic
globalThis() JSValue
Returns a reference to globalThis.
globalThisRaw() → dynamic
hasProperty(JSValue o, String name) bool
Checks for a String name on a JS object o.
hasPropertyRaw(dynamic o, dynamic name) bool
jsify(Object? object) JSValue?
Recursively converts objects from Dart to JS.
jsifyRaw(Object? object) → dynamic
newObject() JSValue
Creates a new JS object literal and returns it.
newObjectRaw() → dynamic
setProperty(JSValue o, String name, JSValue? value) JSValue?
Sets a JS property with String name on JS object o to the JS value value, then returns value.
setPropertyRaw(dynamic o, dynamic name, dynamic value) → dynamic