Running and Debugging Dart Command-Line Applications
This feature is supported in the Professional edition only.
With PyCharm, you can run and debug Dart command line applications. PyCharm supports two debugging modes:
- Local debugging: in this mode, your application is started from PyCharm and is running locally on your computer. To run or debug it, use a Dart Command Line App configuration.
- Debugging a remote application: in this mode, your application is running in a remote environment, for example, in a Docker container. To debug it, use a Dart Remote Debug configuration.
Running a Dart command-line application
- Open the the Dart file to start the application from or select it in the Project view. This file must contain a
main()
method. - On the context menu of the selection, choose Run '<dart_file_name>'. PyCharm 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
- Configure and set breakpoints in the Dart code.
- Open the the Dart file to start the application from or select it in the Project view. This file must contain a
main()
method. - On the context menu of the selection, choose Debug '<dart_file_name>'. PyCharm generates a run/debug configuration of the type Dart Command Line App and starts a debugging session with it.
- 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
If your application is running in a remote environment, for example, in a Docker container, you can debug it using a Dart Remote Debug configuration.
To create a Dart Remote Debug run/debug configuration
- On the main menu, choose , click and choose Dart Remote Debug from the list. The Run/Debug Configuration: Dart Remote Debug opens.
- In the Host field, specify the address of the computer where the Dart Virtual Machine is running, the default value is
localhost
. - 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. - From the Search Sources in drop-down list, choose the Dart project to debug if your PyCharm project contains several Dart projects configured as content roots.
To launch a remote debugging session
- 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. - Choose the newly created Dart Remote Debug configuration in the Select run/debug configuration drop-down list and click .
- 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: 9 August 2017