PhpStorm 2017.2 Help

Dart

PhpStorm supports developing, running, and debugging Dart web and command-line applications. PhpStorm recognizes *.dart files and marks them with the icon_dart_file.png icon.

When the Dart support is enabled, PhpStorm provides full coding assistance, which involves code completion, error and syntax highlighting, code inspections and quick-fixes, search and navigation, refactoring, and much more. PhpStorm also integrates with the pub tool and the Dart Analysis Server.

Before you start, install and enable the Dart repository plugin on the Plugins page 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 command-line and web Dart applications:

  1. Download and install the Dart SDK.
    The Dart SDK incorporates the Dart Virtual Machine, the Dart Libraries, as well as all the command line tools, including compilers (dart2js and dartdevc) and the pub tool.
  2. For web development, optionally download the Dartium browser.
    This browser provides native Dart support so you can run and debug Dart code without previously compiling it into JavaScript.

Learn more about the Dart development tools from the Dart Official website.

Configuring Dart support in a PhpStorm project

You can create a PhpStorm project with Dart-specific structure from a Stagehand template or add Dart support in an existing PhpStorm project.

To create a Dart project from a template:

  1. Choose File | New Project on the main menu or click Create New Project on the Welcome screen. The New Project Dialog opens.
  2. In the left-hand pane, choose Dart.
  3. In the right-hand pane, specify the project name and the path to the folder where the project-related files will be stored.
  4. Specify the paths to the Dart SDK and optionally to the Dartium executable file (Windows and Linux)/Dartium application (macOS). PhpStorm detects and displays the Dart version.
  5. To have a sample application created in the project, select the Generate sample content check box and choose the relevantStagehand template from the list below. If you clear the check box, PhpStorm creates and empty project.
  6. Click Create. PhpStorm sets up the project structure and generates some sources based on the selected Stagehand template.

To configure Dart support in an existing project:

  1. Open the Dart page (File | Settings | Languages and Frameworks | Dart for Windows and Linux or PhpStorm | Preferences | Languages and Frameworks | Dart for macOS).
  2. Select the Enable Dart support for the project <project name> check box.
  3. In the Dart SDK Path text box, specify the location of the downloaded Dart SDK. Type the path manually or click browseButton.png and choose the path in the dialog box that opens. If PhpStorm recognizes the Dart SDK correctly, its revision number is displayed in the Version read-only field.
  4. For Dart web development: optionally specify the location of the Dartium executable (Windows and Linux)/Dart application (macOS). Type the path manually or click browseButton.png and choose the path in the dialog box that opens. Learn more about Dart web tools from the the Dart Official website,

Adding a Dart project (package) to a PhpStorm project

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

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

  1. Open the Directories page (File | Settings | Directories for Windows and Linux or PhpStorm | Preferences | Directories for macOS).
  2. In the right-hand pane with a list of 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

Reference:

Language and Framework-Specific Guidelines:

Last modified: 19 July 2017