Appearance
ListToJSArray<T extends JSAny?>
Conversions from List to JSArray.
Properties
toJS extension no setter
JSArray<T> get toJSConverts this List to a JSArray by either casting, unwrapping, or cloning the List.
INFO
Depending on whether code is compiled to JavaScript or Wasm, this conversion will have different semantics.
When compiling to JavaScript, the core List is a JavaScript Array, and therefore this getter simply casts. If the List is not a core List e.g. a user-defined list, this getter throws with a cast error.
When compiling to Wasm, this List is a wrapper around an Array if it was converted via JSArrayToList.toDart. If it's a wrapper, this getter unwraps it and returns the Array. If it's instantiated in Dart, this getter clones this List's values into a new JSArray.
Avoid assuming that modifications to this List will affect the returned JSArray and vice versa in all compilers unless it was first converted via JSArrayToList.toDart.
Available on List<E>, provided by the ListToJSArray<T extends JSAny?> extension
Implementation
dart
external JSArray<T> get toJS;toJSProxyOrRef extension no setter
JSArray<T> get toJSProxyOrRefConverts this List to a JSArray by either casting, unwrapping, or proxying the List.
INFO
Depending on whether code is compiled to JavaScript or Wasm, this conversion will have different semantics.
When compiling to JavaScript, the core List is a JavaScript Array, and therefore this getter simply casts. If the List is not a core List e.g. a user-defined list, this getter throws with a cast error.
When compiling to Wasm, this List is a wrapper around an Array if it was converted via JSArrayToList.toDart. If it's a wrapper, this getter unwraps it and returns the Array. If it's instantiated in Dart, this getter proxies the List using a heavyweight Array wrapper. Access to the original List's elements may be very unperformant.
Modifications to this List will affect the returned JSArray and vice versa.
Available on List<E>, provided by the ListToJSArray<T extends JSAny?> extension
Implementation
dart
external JSArray<T> get toJSProxyOrRef;