Type conversion
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.
Direct type conversion
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 = ...
Get Dart: Scalable Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.