All the code we've seen so far was based on the automatic type conversion that happens inside the dart:js
library. This conversion always happens in both directions. Once you know how this happens, you will have a better understanding of the limits of that solution and it will help you avoid mistakes.
Dart supports the following small subset of types by directly converting them from the JavaScript types:
null
,bool
,num
,String
, andDateTime
(basic types)Blob
Event
HtmlCollection
ImageData
KeyRange
Node
NodeList
TypedData
(including its subclasses such asInt32List
, but notByteBuffer
)Window
Here is set of different types of JavaScript variables that we prepared in the JavaScript file:
var v_null = null; var v_bool = true; var v_num = 1.2; var v_str = "Hello"; var v_date = new Date(); var v_blob = new Blob( ['<a id="a"><b id="b">hey!</b></a>'], {type : 'text/html'}); var v_evt = new Event('click'); var v_nodes = document...