JSValue class

A JavaScript value. The base type for all JavaScript values, and polymorphic functions on them.

Implemented types
Mixed-in types
  • AutoDisposeFinalizer
Available extensions

Constructors

JSValue.new(JSContext context, JSValueRef _ref, {bool autoDispose = true})
JSValue.makeBoolean(JSContext context, bool boolean, {bool autoDispose = true})
Creates a JavaScript value of the boolean type. boolean The bool to assign to the newly created JSValue.
JSValue.makeError(JSContext context, String message)
factory
JSValue.makeFromJSONString(JSContext context, String string, {bool autoDispose = true})
Creates a JavaScript value from a JSON formatted string. string The JSString containing the JSON string to be parsed.
factory
JSValue.makeNull(JSContext context, {bool autoDispose = true})
Creates a JavaScript value of the null type.
JSValue.makeNumber(JSContext context, double number, {bool autoDispose = true})
Creates a JavaScript value of the number type. number The double to assign to the newly created JSValue.
JSValue.makeString(JSContext context, String string, {bool autoDispose = true})
Creates a JavaScript value of the string type. string The double to assign to the newly created JSValue.
factory
JSValue.makeSymbol(JSContext context, String description, {bool autoDispose = true})
Creates a JavaScript value of the symbol type. description A description of the newly created symbol value.
factory
JSValue.makeUndefined(JSContext context, {bool autoDispose = true})
Creates a JavaScript value of the undefined type.

Properties

boolean bool
Converts a JavaScript value to boolean and returns the resulting boolean.
no setter
context JSContext
JavaScript context
final
getTypedArrayType JSTypedArrayType
Returns a JavaScript value's Typed Array type.iOS 10.0
no setter
hashCode int
The hash code for this object.
no setteroverride
isArray bool
Tests whether a JavaScript value is an array. iOS 9.0
no setter
isBoolean bool
Tests whether a JavaScript value's type is the boolean type.
no setter
isDate bool
Tests whether a JavaScript value is a date. iOS 9.0
no setter
isError bool
no setter
isFunction bool
no setter
isMap bool
no setter
isNull bool
Tests whether a JavaScript value's type is the null type.
no setter
isNumber bool
Tests whether a JavaScript value's type is the number type.
no setter
isObject bool
Tests whether a JavaScript value's type is the object type.
no setter
isPromise bool
no setter
isRegExp bool
no setter
isSet bool
no setter
isString bool
Tests whether a JavaScript value's type is the string type.
no setter
isSymbol bool
Tests whether a JavaScript value's type is the symbol type.
no setter
isUndefined bool
Tests whether a JavaScript value's type is the undefined type.
no setter
jsonString String?
no setter
nativeFinalizer NativeFinalizer?
dart 对象回收器
getter/setter pairinherited
number double
Converts a JavaScript value to number and returns the resulting number. exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
no setter
object JSObject
Converts a JavaScript value to object and returns the resulting object. exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
no setter
ref JSValueRef
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
string String?
Converts a JavaScript value to number and returns the resulting string.
no setter
stringCopy JSString
Converts a JavaScript value to string and copies the result into a JavaScript string. exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
no setter
type JSType
Value type
no setter

Methods

attach(Pointer<NativeFinalizerFunction> callback, Pointer<Void> token, {bool autoDispose = true, Object? detach, int? externalSize}) → dynamic
将引擎持有的指针和 dart 对象回收器绑定。确保 dart 对象销毁的时候,释放引擎持有的指针和资源
inherited
createJSONString({int indent = 2, bool autoDispose = true}) JSString
Creates a JavaScript string containing the JSON serialized representation of a JS value. indent The number of spaces to indent when nesting. If 0, the resulting JSON will not contains newlines. The size of the indent is clamped to 10 spaces. exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
detach() → dynamic
将引擎持有的指针和资源释放
inherited
free() → void
isEqual(JSValue other) bool
Tests whether two JavaScript values are equal, as compared by the JS == operator.
isInstanceOfConstructor(JSObject constructor) bool
Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.
isObjectOfClass(JSClass jsClass) bool
Tests whether a JavaScript value's type is the symbol type. jsClass The JSClass to test against.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
protect() → void
Protects a JavaScript value from garbage collection. Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it.
toDart() → dynamic

Available on JSValue, provided by the JSValueToNative extension

toString() String
A string representation of this object.
override
unprotect() → void
Unprotects a JavaScript value from garbage collection. A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection.

Operators

operator ==(Object other) bool
Tests whether two JavaScript values are strict equal, as compared by the JS === operator.
override