O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compiling your app to JavaScript

Deploying a Dart app in a browser means running it in a JavaScript engine, so the Dart code has to first be compiled to JavaScript. This is done through the dart2js tool, which is itself written in Dart and lives in the bin subfolder of dart-sdk. The tool is also nicely integrated in Dart Editor.

How to do it...

  • Right-click on .html or the .dart file and select Run as JavaScript.
  • Alternatively, you can right-click on the pubspec.yaml file and select Pub Build (generates JS) from the context menu. You can also click on the Tools menu while selecting the same file, and then on Pub Build.

How it works...

The first option invokes the pub serve command to start a local web server invoking dart2js along its way in the checked ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required