Dartium: Chromium with the Dart VM

Dartium is a special build of Chromium that includes the Dart VM. Using Dartium means you don’t have to compile your code to JavaScript until you’re ready to test on other browsers.

To learn about other tools you can use for Dart development, see Dart Tools.

Getting Dartium

If you use Homebrew on the Mac, you can include Dartium as part of the Dart SDK download.

Otherwise, you can download Dartium directly:

For other versions of Dartium, including dev channel releases, see the download index.

Installing Dartium

You don’t usually need to do anything special to install Dartium. However, you may need to configure your IDE so that it can find Dartium. In WebStorm, for example, you can do this in Preferences > Languages & Frameworks > Dart. In the Dartium path field, type or browse to the location of the Chromium executable.

Launching Dartium

To launch Dartium, navigate to its directory in your finder, and double-click the Chromium executable file. Or launch a web app from your IDE, or at the command line as described in Using command-line flags.

Linking to Dart source

Use a script tag with a type application/dart to link to your main Dart source file. Example:

<!DOCTYPE html>
<html>
  <body>
    <script type="application/dart" src="main.dart"></script>

    <!-- Support for non-Dart browsers. -->
    <script src="packages/browser/dart.js"></script>
  </body>
</html>

For more information on linking to source code, see the article Embedding Dart in HTML.

Advanced use cases

This section contains advanced information. If you need to detect whether Dart is supported in the browser, set the API keys in order to use one of the Google APIs, or specify Dartium flags at the command line, read on. Otherwise, you can skip this section.

Detecting Dart support

You can check whether a browser supports Dart with this JavaScript code:

// In JavaScript code:
if (navigator.userAgent.indexOf('(Dart)') == -1) {
  // No native Dart support...
  window.addEventListener("DOMContentLoaded", function (e) {
      // ...Fall back to compiled JS...
    }
  }, false);
}

Setting API keys

To use some features in the Google APIs, such as geolocation from the Google Maps API, you need to set the API keys in Dartium. You can either build a special version of Dartium with the API keys baked in, or you can specify the keys at runtime. For more information on how to acquire and use API keys, see API Keys.

Using command-line flags

Because Dartium is based on Chromium, all Chromium flags should work. In some cases, you might want to specify Dart-specific flags so that you can tweak the embedded Dart VM’s behavior. For example, while developing your web app, you might want the VM to verify type annotations and check assertions. To achieve that, you can enable checked mode (the VM’s --checked flag).

On Linux, you can specify flags by starting Dartium as follows:

DART_FLAGS='--checked' path/chrome

On Mac:

DART_FLAGS='--checked'              \
  path/Chromium.app/Contents/MacOS/Chromium

Or (also on Mac):

DART_FLAGS='--checked'              \
   open path/Chromium.app

Filing bugs and feature requests

To see existing issues, view Dartium bugs in the SDK project. You can file a bug on GitHub.