Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:js_interop
dart:js_interop
description

dart:js_interop library

Interoperability, "interop" for short, with JavaScript and browser APIs.

JavaScript interop allows a Dart program to interact with a JavaScriptruntime. This can, for example, be to access JavaScript declarations andinteract with JavaScript values, or to adapt Dart values so that they can bepassed to and used by JavaScript code.

This JavaScript interop library works by introducing an abstraction overJavaScript values, a Dart type hierarchy ("JS types") which mirrors knownJavaScript types, and a framework for introducing new Dart types that bindDart type declarations to JavaScript values and external member declarationsto JavaScript APIs.

This abstraction allows the same interop API to be used both when the Dartcode is compiled to JavaScript and when compiled to Wasm.

Seehttps://dart.dev/interop/js-interop for more details on usage, types,and previous JavaScript interop.

Note

The types defined in this library only provide static guarantees. Theruntime types differ based on the backend, so it is important to rely onstatic functionality like the conversion functions. Similarly, don't relyonis checks that involve JS types or JS-typed values. Furthermore,identical may also return different results for the same JS valuedepending on the compiler. Use== to check for equality of two JS-typedvalues instead, but do not check for equality between a Dart value and aJS-typed value.

Classes

JS
An annotation on a JavaScript interop declaration.
JSExport
Annotation to allow Dart classes to be wrapped with a JS object usingdart:js_interop'screateJSInteropWrapper.

Extension Types

ExternalDartReference
An opaque reference to a Dart object that can be passed to JavaScript.
JSAny
A non-nullish JavaScript value.
JSArray
A JavaScriptArray.
JSArrayBuffer
A JavaScriptArrayBuffer.
JSBigInt
A JavaScriptBigInt.
JSBoolean
A JavaScript boolean.
JSBoxedDartObject
A Dart object that is wrapped with a JavaScript object so that it can bepassed to JavaScript safely.
JSDataView
A JavaScriptDataView.
JSExportedDartFunction
A JavaScript callable function created from a Dart function.
JSFloat32Array
A JavaScriptFloat32Array.
JSFloat64Array
A JavaScriptFloat64Array.
JSFunction
A JavaScriptFunctionvalue.
JSInt16Array
A JavaScriptInt16Array.
JSInt32Array
A JavaScriptInt32Array.
JSInt8Array
A JavaScriptInt8Array.
JSNumber
A JavaScript number.
JSObject
A JavaScriptObject.
JSPromise
A JavaScriptPromise or a promise-like object.
JSString
A JavaScript string.
JSSymbol
A JavaScriptSymbol.
JSTypedArray
Abstract supertype of all JavaScript typed arrays.
JSUint16Array
A JavaScriptUint16Array.
JSUint32Array
A JavaScriptUint32Array.
JSUint8Array
A JavaScriptUint8Array.
JSUint8ClampedArray
A JavaScriptUint8ClampedArray.

Extensions

BoolToJSBoolean onbool
Conversions frombool toJSBoolean.
ByteBufferToJSArrayBuffer onByteBuffer
Conversions fromByteBuffer toJSArrayBuffer.
ByteDataToJSDataView onByteData
Conversions fromByteData toJSDataView.
DoubleToJSNumber ondouble
Conversions fromdouble toJSNumber.
ExternalDartReferenceToObject onExternalDartReference<T>
Conversions fromExternalDartReference to the value of typeT.
Float32ListToJSFloat32Array onFloat32List
Conversions fromFloat32List toJSFloat32Array.
Float64ListToJSFloat64Array onFloat64List
Conversions fromFloat64List toJSFloat64Array.
FunctionToJSExportedDartFunction onFunction
Conversions fromFunction toJSExportedDartFunction.
FutureOfJSAnyToJSPromise onFuture<T>
Conversions fromFuture toJSPromise where theFuture returns a value.
FutureOfVoidToJSPromise onFuture<void>
Conversions fromFuture toJSPromise where theFuture does not returna value.
Int16ListToJSInt16Array onInt16List
Conversions fromInt16List toJSInt16Array.
Int32ListToJSInt32Array onInt32List
Conversions fromInt32List toJSInt32Array.
Int8ListToJSInt8Array onInt8List
Conversions fromInt8List toJSInt8Array.
JSAnyOperatorExtension onJSAny?
General-purpose JavaScript operators.
JSAnyUtilityExtension onJSAny?
Common utility functions that are useful for any JavaScript value.
JSArrayBufferToByteBuffer onJSArrayBuffer
Conversions fromJSArrayBuffer toByteBuffer.
JSArrayToList onJSArray<T>
Conversions fromJSArray toList.
JSBooleanToBool onJSBoolean
Conversions fromJSBoolean tobool.
JSBoxedDartObjectToObject onJSBoxedDartObject
Conversions fromJSBoxedDartObject toObject.
JSDataViewToByteData onJSDataView
Conversions fromJSDataView toByteData.
JSExportedDartFunctionToFunction onJSExportedDartFunction
Conversions fromJSExportedDartFunction toFunction.
JSFloat32ArrayToFloat32List onJSFloat32Array
Conversions fromJSFloat32Array toFloat32List.
JSFloat64ArrayToFloat64List onJSFloat64Array
Conversions fromJSFloat64Array toFloat64List.
JSFunctionUtilExtension onJSFunction
Utility extensions forJSFunction.
JSInt16ArrayToInt16List onJSInt16Array
Conversions fromJSInt16Array toInt16List.
JSInt32ArrayToInt32List onJSInt32Array
Conversions fromJSInt32Array toInt32List.
JSInt8ArrayToInt8List onJSInt8Array
Conversions fromJSInt8Array toInt8List.
JSNumberToNumber onJSNumber
Conversions fromJSNumber todouble orint.
JSPromiseToFuture onJSPromise<T>
Conversions fromJSPromise toFuture.
JSStringToString onJSString
Conversions fromJSString toString.
JSUint16ArrayToUint16List onJSUint16Array
Conversions fromJSUint16Array toUint16List.
JSUint32ArrayToUint32List onJSUint32Array
Conversions fromJSUint32Array toUint32List.
JSUint8ArrayToUint8List onJSUint8Array
Conversions fromJSUint8Array toUint8List.
JSUint8ClampedArrayToUint8ClampedList onJSUint8ClampedArray
Conversions fromJSUint8ClampedArray toUint8ClampedList.
ListToJSArray onList<T>
Conversions fromList toJSArray.
NullableObjectUtilExtension onObject?
Common utility functions forObject?s.
NullableUndefineableJSAnyExtension onJSAny?
Helper members to determine if a value is JavaScriptundefined ornull.
NumToJSExtension onnum
Conversions fromnum toJSNumber.
ObjectToExternalDartReference on T
Conversions from a value of typeT toExternalDartReference.
ObjectToJSBoxedDartObject onObject
Conversions fromObject toJSBoxedDartObject.
StringToJSString onString
Conversions fromString toJSString.
Uint16ListToJSUint16Array onUint16List
Conversions fromUint16List toJSUint16Array.
Uint32ListToJSUint32Array onUint32List
Conversions fromUint32List toJSUint32Array.
Uint8ClampedListToJSUint8ClampedArray onUint8ClampedList
Conversions fromUint8ClampedList toJSUint8ClampedArray.
Uint8ListToJSUint8Array onUint8List
Conversions fromUint8List toJSUint8Array.

Constants

anonymous→ const _Anonymous
An annotation that indicates aJS annotated class is structural and doesnot have a known JavaScript prototype.
staticInterop→ const _StaticInterop
staticInterop enables theJS annotated class to be treated as a "static"interop class.

Properties

globalContextJSObject
The global scope that is used to find user-declared interop members.
no setter

Functions

createJSInteropWrapper<T extendsObject>(TdartObject, [JSObject?proto =null])JSObject
Given a instance of a Dart class that contains an@JSExportannotation, creates a JavaScript object that wraps the given Dart object.
importModule(JSAnymoduleName)JSPromise<JSObject>
Dynamically imports a JavaScript module with the givenmoduleName usingthe JavaScriptimport() syntax.

Typedefs

JSVoid = void
JS type equivalent forundefined for interop member return types.

Exceptions / Errors

NullRejectionException
Exception for when aJSPromise that is converted viaJSPromiseToFuture.toDart is rejected with anull orundefined value.
  1. Dart
  2. dart:js_interop
DartSDK
  1. Libraries
  2. Core
  3. dart:async
  4. dart:collection
  5. dart:convert
  6. dart:core
  7. dart:developer
  8. dart:math
  9. dart:typed_data
  10. VM
  11. dart:ffi
  12. dart:io
  13. dart:isolate
  14. dart:mirrors
  15. Web
  16. package:webopen_in_new
  17. dart:js_interop
  18. dart:js_interop_unsafe
  19. Web (Legacy)
  20. dart:html
  21. dart:indexed_db
  22. dart:js
  23. dart:js_util
  24. dart:svg
  25. dart:web_audio
  26. dart:web_gl
dart:js_interop library

[8]ページ先頭

©2009-2025 Movatter.jp