ExternalDartReference extension type

An opaque reference to a Dart object that can be passed to JavaScript.

The reference representation depends on the underlying platform. When compiling to JavaScript, a Dart object is a JavaScript object, and can be used directly without any conversions. When compiling to Wasm, an internal Wasm function is used to convert the Dart object to an opaque JavaScript value, which can later be converted back using another internal function.

This interface is a faster alternative to JSBoxedDartObject by not wrapping the Dart object with a JavaScript object. However, unlike JSBoxedDartObject, this value belongs to the Dart runtime, and therefore can not be used as a JS type. This means users cannot declare interop types using this as the representation type or declare interop members on this type. This type is also not a subtype of JSAny. This type can only be used as parameter and return types of external JavaScript interop members or callbacks. Use JSBoxedDartObject to avoid those limitations.

Besides these differences, ExternalDartReference operates functionally the same as JSBoxedDartObject. Use it to pass Dart objects within the same runtime through JavaScript. There are no usable members in the resulting ExternalDartReference.

See ObjectToExternalDartReference.toExternalReference to allow an arbitrary Object to be passed to JavaScript.

on
  • ExternalDartReferenceRepType
Implemented types

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited