Using Dart in JavaScript and JavaScript in Dart is very easy, although there are some limitations right now that will hopefully be resolved in the future. Basically, when exchanging data between JavaScript and Dart, all you have to do is to wrap/unwrap Dart objects with JsArray
, JsFunction
, or JsObject
proxy classes from the dart:js
built-in package.
Some built-in types don't need any proxy wrapper. The most common are null
, bool
, num
, String
, DateTime
, HtmlCollection
, Event
, Node
, and NodeList
.
Note
Maybe you've already seen somebody using a package:js
/js.dart
package. This is the old Dart-JS interoperation package, which is deprecated in favor of dart:js
.