Using Integration with the Pub Tool
You can also use the pub tool in the command line mode from the embedded local terminal.
Execution of the pub tool commands is logged in the Messages Tool Window. In this tool window, you can examine the tool log and re-run the last executed command by clicking on the toolbar.
On this page:
- Managing Dart Dependencies
- Building a Dart Application
Managing Dart Dependencies
WebStorm provides interface for running the pub get
and pub upgrade actions from the editor.
As soon as you open a pubspec.yaml file in the editor, WebStorm displays a Pub actions pane
at the top of the
pubspec.yaml editor tab. You can use the links on this pane or use the context menu of the editor
pubspec.yaml file in the Project tool window.
The pub tool saves the downloaded packages in caches, creates a
packages folder next
pubspec.yaml file which contains information on packages and their dependencies.
web folder, the pub tool creates a copy of the
packages folder. As soon as a subfolder if created under the
a copy of the
packages folder is created in the new subfolder.
All the copies of the
packages folder are automatically excluded from the project, that is, they are not indexed. WebStorm excludes these copies on opening a project
and every time the pub get or pub upgrade action is invoked.
All the excluded copies of the
packages folder are listed in the exclusion list on the Directories page.
You can remove a copy from this list but the copy will be restored during the first automatic exclusion.
To download or upgrade dependencies:
pubspec.yamlfile in the editor.
- To detect and download dependencies, do one of the following:
- To download the up-to-date versions of the existing dependencies, do one of the following:
If for some reasons the previously downloaded and stored in a cache dependencies are broken, you can clear the cache and download the dependencies anew:
When running and debugging Dart web applications, WebStorm uses the Pub Serve tool.
Integration with it is established through the built-in server which acts transparently as a proxy server
between your application and the Pub Serve tool.
In other words, integration with the Pub Serve tool works invisibly and you do not need to care about it.
The tool is invoked automatically when you run or debug a Dart web application, either by opening an HTML file or by launching a run/debug configuration.
The tool analyzes the
<script></script> element in the HTML file. If the element references a Dart file, Pub Serve invokes the Dart2js compiler
The work of the Pub Serve tool is logged in the dedicated Pub Serve tool window which opens when you start running or debugging a Dart web application for the first time during the current WebStorm session. You can stop the tool by clicking on the toolbar. As soon as you start running or debugging again, the tool restarts automatically.
See Running and Debugging Dart Web Applications for details.
Building a Dart Application
WebStorm provides interface for using the pub tool which builds applications
through the pub build action.
using the dart2js,
and stores all the output in the automatically created
build folder. The folder is marked as excluded,
see Configuring Folders Within a Content Root.
See Assets and Transformers for details.
To build a Dart application:
pubspec.yamlfile in the editor or switch to the tab where it is opened.
- On the pub pane at the top of the tab, click Build.
In the dialog box that opens, choose the build mode which determines the behaviour of the dart2js tool:
new lines, comments without affecting the functionality of the source code.
In the Release mode, the source
.dartfiles are not included in the build output. This mode is applicable when you are going to publish your application.
- Other: choose this option if you want to use a custom transformer and specify the path to it.