dart:js_util#
Utility methods to manipulate package:js annotated JavaScript interop
objects in cases where the name to call is not known at runtime.
You should usually use dart:js_interop instead of this library.
To learn more, check out the
JS interop documentation.
You should only use these methods when the same effect cannot be achieved
with @JS() annotations.
Exceptions#
| Exception | Description |
|---|---|
| NullRejectionException |
Exception for when a
JSPromise
that is converted via
JSPromiseToFuture.toDart
is rejected with a
null
or
undefined
value.
|
Functions#
| Function | Description |
|---|---|
| add<T> | Perform JavaScript addition (+) on two values. |
| allowInterop<F extends Function> |
Returns a wrapper around function
f
that can be called from JavaScript using
package:js
JavaScript interop.
|
| allowInteropCaptureThis |
Returns a wrapper around function
f
that can be called from JavaScript using
package:js
JavaScript interop, passing JavaScript
this
as the first argument.
|
| and<T> | Perform JavaScript logical and comparison (&&) of two expressions. |
| callConstructor<T> | |
| callMethod<T> | |
| createDartExport<T extends Object> |
Given a Dart object that is marked exportable, creates a JS object literal that forwards to that Dart class. Look at the
@JSExport
annotation to determine what constitutes "exportable" for a Dart class. The object literal will be a map of export names (which are either the written instance member names or their rename) to their respective Dart instance members.
|
| createStaticInteropMock<T extends Object, U extends Object> |
Given a
@staticInterop
type T and an instance
dartMock
of a Dart class U that implements the external extension members of T, creates a forwarding mock.
|
| dartify | Effectively the inverse of jsify , dartify Takes a JavaScript object, and converts it to a Dart based object. Only JS primitives, arrays, or 'map' like JS objects are supported. |
| delete<T> | Perform JavaScript delete operator (delete) on the given property of the given object. |
| divide<T> | Perform JavaScript division (/) on two values. |
| equal<T> | Perform JavaScript equality comparison (==) on two values. |
| exponentiate<T> | Perform JavaScript exponentiation (**) on two values. |
| getProperty<T> | |
| greaterThan<T> | Perform JavaScript greater than comparison (>) of two values. |
| greaterThanOrEqual<T> | Perform JavaScript greater than or equal comparison (>=) of two values. |
| hasProperty | |
| instanceof | Check whether o is an instance of type. |
| instanceOfString | Like instanceof only takes a String for the object name instead of a constructor object. |
| isJavaScriptArray | Returns true if a given object is a JavaScript array. |
| isJavaScriptSimpleObject | Returns true if a given object is a simple JavaScript object. |
| isTruthy<T> | Determines if the given object is truthy or falsy. |
| jsify | Recursively converts a JSON-like collection to JavaScript compatible representation. |
| lessThan<T> | Perform JavaScript less than comparison (<) of two values. |
| lessThanOrEqual<T> | Perform JavaScript less than or equal comparison (<=) of two values. |
| modulo<T> | Perform JavaScript remainder (%) on two values. |
| multiply<T> | Perform JavaScript multiplication (*) on two values. |
| newObject<T> | |
| not<T> | Perform JavaScript logical not (!) on the given object. |
| notEqual<T> | Perform JavaScript inequality comparison (!=) on two values. |
| objectGetPrototypeOf | Returns the prototype of a given object. Equivalent to Object.getPrototypeOf. |
| objectKeys | Returns the keys for a given object. Equivalent to Object.keys(object). |
| or<T> | Perform JavaScript logical or comparison (||) of two expressions. |
| promiseToFuture<T> | Converts a JavaScript Promise to a Dart Future . |
| setProperty<T> | |
| strictEqual<T> | Perform JavaScript strict equality comparison (===) on two values. |
| strictNotEqual<T> | Perform JavaScript strict inequality comparison (!==) on two values. |
| subtract<T> | Perform JavaScript subtraction (-) on two values. |
| typeofEquals<T> |
Perform JavaScript
typeof
operator on the given object and determine if the result is equal to the given type. Exposes the whole
typeof
equal expression to maximize browser optimization.
|
| unsignedRightShift |
Perform JavaScript unsigned right shift operator (
>>>
) on the given left operand by the amount specified by the given right operand.
|
Properties#
| Property | Description |
|---|---|
| globalThis | |
| objectPrototype | Returns the Object prototype. Equivalent to Object.prototype. |