PhpStorm 2017.2 Help

Running and Debugging Dart Command-Line Applications

With PhpStorm, you can run and debug Dart command line applications. PhpStorm supports two debugging modes:

  • Local debugging is initiated through a run/debug configuration of the type Dart Command Line App.
  • Debugging of a remote application is initiated through a run/debug configuration of the type Dart Remote Debug.

On this page:

Running a Dart command-line application

  1. Open the the Dart file to start the application from or select it in the Project view. This file must contain a main() method.
  2. On the context menu of the selection, choose Run '<dart_file_name>'. PhpStorm generates a run/debug configuration of the type Dart Command Line App and launches your application with it.

Debugging a Dart command-line application locally

  1. Configure and set breakpoints in the Dart code.
  2. Open the the Dart file to start the application from or select it in the Project view. This file must contain a main() method.
  3. On the context menu of the selection, choose Debug '<dart_file_name>'. PhpStorm generates a run/debug configuration of the type Dart Command Line App and starts a debugging session with it.
  4. In the Debug Tool Window that opens, step through the program, stop and resume program execution, examine it when suspended, etc.

Debugging a remote Dart command-line application

In this mode, the debugger connects to a remote DartVM. A debugging session is initiated via a Dart Remote Debug run/debug configuration.

To create a Dart Remote Debug run/debug configuration:

  1. On the main menu, choose Run | Edit Configurations, click add.png and choose Dart Remote Debug from the list. The Run/Debug Configuration: Dart Remote Debug opens.
  2. In the Host field, specify the address of the computer where the Dart Virtual Machine is running, the default value is localhost.
  3. Specify the port through which the debugger will connect to the remote application, the default value is 5858. The specified port is shown in the Use the command line arguments when starting the remote VM read-only field. Note that a remote application must be started exactly with these arguments.
  4. From the Search Sources in drop-down list, If your PhpStorm project contains several Dart projects configured as content roots, choose the Dart project to debug.

To launch a remote debugging session:

  1. Start a remote Dart application with the VM options from the Command line arguments for the remote Dart VM field in the Dart Remote Debug run configuration, for example, --enable-vm-service:5858 --pause_isolates_on_start.The application starts, immediately suspends thanks to the --pause_isolates_on_start argument, and waits for the debugger to connect.
  2. Choose the newly created Dart Remote Debug configuration in the Select run/debug configuration drop-down list and click /help/img/idea/2017.2/debug.png.
  3. In the Debug Tool Window that opens, step through the program, stop and resume program execution, examine it when suspended, etc.

See Also

Last modified: 19 July 2017