Tutorial by Examples

Suppose we'd like to invoke the JavaScript function JSON.stringify which receives an object, encodes it into a JSON string and returns it. All we'd have to do is write the function signature, mark it as external and annotate it with the @JS annotation: @JS("JSON.stringify") external St...
Suppose we'd like to wrap the Google Maps JavaScript API google.maps: @JS('google.maps') library maps; import "package:js/js.dart"; @JS() class Map { external Map(Location location); external Location getLocation(); } We now have the Map Dart class which corresponds to t...
It's common practice in JavaScript to pass object literals to functions: // JavaScript printOptions({responsive: true}); Unfortunately we cannot pass Dart Map objects to JavaScript in these cases. What we have to do is create a Dart object that represents the object literal and contains all of...

Page 1 of 1