IntelliJ IDEA 2016.3 Help

Preparing for Dart Development

On this page:

Before you start

Install and enable the Dart plugin. The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins. The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.

Downloading the Dart tools

To have all the tools for developing both server-side and client-side applications, download the Dart SDK and the Dartium browser in which you can run Dart code without previously transpiling it into JavaScript. The Dart SDK incorporates the Dart Virtual Machine, the Dart Libraries, and all the background command line tools, the most important of them being the dart2js transpiler and the Dart-specific pub package manager.

Learn more about Dart development tools at the Dart Download Page.

Configuring Dart support in a project

To develop a Dart application you need to tell IntelliJ IDEA where the Dart SDK and the Dartium executable file are located. If you are using the Dart project template, IntelliJ IDEA will ask you to specify these settings during the project creation. Alternatively you can specify these paths at any time later on the Dart page of the Settings dialog box.

These settings are specific for each project. This means that you can have several Dart SDKs and Dartium installations in IntelliJ IDEA and switch between them from one project to another.

Next, you need a project with Dart-specific structure. If you are using the Dart project template, IntelliJ IDEA establishes the required folder structure for you automatically. Alternatively, you can add and arrange the necessary folders manually.

Creating a Dart application stub

During project creation, IntelliJ IDEA can generate a stub for developing Dart applications. The project structure is set up and some sources are generated based on the external Dart templates downloaded upon your request.

  1. Choose File | New | Project on the main menu or click the New Project button on the Welcome screen.
  2. In the Project Category and Options dialog, which is the first page of the New Project wizard, choose Dart in the left-hand pane.
  3. In the right-hand pane, specify the paths to the Dart SDK and to the Dartium executable file. IntelliJ IDEA detects and displays the Dart version. If the SDK was downloaded within the Dart Editor Bundle, the path to Dartium is also detected and filled in automatically. Click Next.
  4. On the second page of the wizard,
    1. In the Location text box, specify the path to the project folder where the project-related files will be stored.
    2. Specify the paths to the Dart SDK and to the Dartium executable file. IntelliJ IDEA detects and displays the Dart version. If the SDK was downloaded within the Dart Editor Bundle, the path to Dartium is also detected and filled in automatically.
    3. To have annotations verified and assertions checked, select the Start Dartium in checked mode check box. Learn more about Dartium command line flags at https://www.dartlang.org/tools/dartium/.
    Click Finish when ready.

If necessary, you can open the Dart page of the Settings dialog box by clicking the Settings button and configure command-line options and a custom user data directory for Dartium.

Configuring Dart support in an existing project

Besides creating a Dart project from the very beginning, you can configure Dart support in a project at any stage of its development.

  1. Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for OS X, and click Dart under Languages & Frameworks.
  2. Select the Enable Dart support in project <project name> check box whereupon all the fields below become available.
  3. In the Dart SDK Path text box, specify the location of the downloaded Dart SDK. Type the path manually or click the Browse button browseButton.png and choose the path in the dialog box that opens.

    If IntelliJ IDEA recognizes the Dart SDK correctly, it displays the revision number of the detected SDK in the Version read-only field.

  4. In the Dartium Path text box, specify the location of the Dartium executable file. In the Dartium browser, you can run Dart code without previously transpiling it into JavaScript. Type the path manually or click the Browse button browseButton.png and choose the path in the dialog box that opens. If the SDK was downloaded within the Dart Editor Bundle, the path to Dartium is also detected and filled in automatically. Learn more about Dart development tools at the Dart Download Page.
  5. To have annotations verified and assertions checked, select the Start Dartium in checked mode check box. Learn more about Dartium command line flags at https://www.dartlang.org/tools/dartium/.
  6. In the Enable Dart support for the following modules area, select the check boxes next to the names of the modules where you need Dart support. If you want to use a custom Dart package in a module, specify the location of the packages in the Custom package roots field.

    IntelliJ IDEA detects the specified Dart SDK and adds it as module dependencies, see Configuring Module Dependencies and Libraries.

Developing several Dart projects (packages) within one IntelliJ IDEA project

If your application consists of several Dart projects (packages), you can develop all of them within one single IntelliJ IDEA project. To attach a Dart project (package) to an existing IntelliJ IDEA project you need to add its root folder as a content root.

To add a Dart project (package) to an existing IntelliJ IDEA project:

  1. Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for OS X, and click Directories under Project: <project name>.
  2. In the right-hand pane which shows a list of already existing content roots, click Add Content Root. Then in the dialog box that opens, choose the root folder of the Dart project (package) to be attached.

See Also

Last modified: 7 December 2016