If you are learning Dart or setting up a Dart development environment for the first time, knowing the right terminal commands can make your development workflow much easier.
Dart provides a powerful command-line interface that allows you to check your Dart installation, create projects, run applications, analyze code, format source files, manage packages, run tests, and perform many other development tasks directly from the terminal.
Instead of searching for individual commands every time you need to perform an action, this Dart Terminal Commands Cheat Sheet brings the most useful Dart commands together in one place.
This guide explains each important command with its purpose, syntax, example, and practical use, making it useful for both beginners and developers who want a quick Dart command reference.
What Is the Dart Command-Line Interface?
The Dart SDK includes a command-line tool called dart.
Once Dart is installed correctly, you can open your terminal and use commands beginning with:
dart
For example:
dart --version
This command tells you which Dart SDK version is installed on your computer.
The Dart command-line interface is useful because you can perform many development tasks without opening a graphical application.
You can use it to:
- Check Dart installation
- Check the Dart SDK version
- Create Dart projects
- Run Dart applications
- Run individual Dart files
- Analyze source code
- Format Dart code
- Run tests
- Manage dependencies
- Add packages
- Remove packages
- Update dependencies
- Get command documentation
Dart Command Syntax
Most Dart terminal commands follow a simple structure:
dart <command> <options> <arguments>
For example:
dart run
Here:
dartis the Dart command-line executable.runis the command.- Additional options or arguments can be added when required.
Another example is:
dart create my_app
Here:
dartstarts the Dart CLI.createtells Dart to create a project.my_appis the project name.
1. dart --version
The first command every Dart developer should know is:
dart --version
What Does It Do?
It displays the Dart SDK version installed on your computer.
Example:
Dart SDK version: 3.x.x
The exact version depends on the Dart SDK installed on your system.
When Should You Use It?
Use this command when:
- You have just installed Dart.
- You want to verify Dart installation.
- You want to check your current SDK version.
- You are troubleshooting a Dart project.
- You want to confirm that your terminal is using the expected Dart installation.
2. dart --help
Command:
dart --help
What Does It Do?
It displays information about the Dart command-line interface and available commands.
It is particularly useful when you forget a command or want to discover available Dart options.
For example:
dart --help
can show commands related to:
- Running applications
- Creating projects
- Analyzing code
- Formatting code
- Testing
- Package management
When Should You Use It?
Use dart --help when:
- You are learning Dart CLI commands.
- You forget the syntax of a command.
- You want to explore Dart CLI features.
3. dart create
Command:
dart create project_name
What Does It Do?
The dart create command creates a new Dart project using one of Dart’s project templates.
For example:
dart create my_dart_app
This creates a project called:
my_dart_app
Dart generates the required project structure and configuration files.
Example
dart create hello_dart
Then move into the project:
cd hello_dart
When Should You Use It?
Use dart create when starting a new Dart project.
4. dart create --help
Command:
dart create --help
What Does It Do?
It displays options available for creating Dart projects.
This is useful when you want to learn about different project templates and project creation options.
For example:
dart create --help
can help you discover the available configuration options.
5. cd
Although cd is not a Dart-specific command, you will use it constantly while working with Dart projects.
Command:
cd project_name
What Does It Do?
cd means Change Directory.
It moves your terminal into another folder.
For example:
cd my_dart_app
After running this command, the terminal is working inside the my_dart_app directory.
Why Is It Important?
Most Dart commands are executed from inside your Dart project directory.
For example:
cd my_dart_app
dart run
6. dart run
Command:
dart run
What Does It Do?
It runs the Dart application in the current project.
For example:
cd my_dart_app
dart run
Dart finds the project’s executable entry point and runs the application.
When Should You Use It?
Use dart run whenever you want to execute a Dart project from the terminal.
7. dart run file.dart
You can also run an individual Dart file.
Command:
dart run file.dart
For example:
dart run hello.dart
If your file contains:
void main() {
print('Hello, Dart!');
}
running:
dart run hello.dart
will execute that program.
When Should You Use It?
This is particularly useful when:
- Learning Dart
- Testing small programs
- Running standalone Dart files
- Practicing Dart syntax
8. dart analyze
Command:
dart analyze
What Does It Do?
The Dart analyzer examines your project and reports potential problems.
It can detect things such as:
- Errors
- Warnings
- Type-related issues
- Unused code
- Other analyzer diagnostics
Example
dart analyze
If there are no issues, Dart will report that the analysis completed without detected problems.
When Should You Use It?
Run this command before committing code or when troubleshooting a Dart project.
9. dart analyze file.dart
You can analyze a particular Dart file instead of the entire project.
Example:
dart analyze lib/main.dart
This is useful when you want to focus on a specific file.
10. dart format
Command:
dart format .
What Does It Do?
The Dart formatter automatically formats Dart source code according to Dart’s formatting conventions.
The . means the current directory.
Example:
dart format .
This formats Dart files in the current project.
Why Is Formatting Important?
Proper formatting makes code:
- Easier to read
- Easier to maintain
- More consistent
- Easier to review
11. Format a Specific File
Command:
dart format file.dart
Example:
dart format main.dart
This formats only the specified Dart file.
This can be useful when you do not want to format the entire project.
12. dart test
Command:
dart test
What Does It Do?
It runs the tests in your Dart project.
For example:
dart test
Dart searches for test files and executes them.
When Should You Use It?
Use this command when your Dart project contains automated tests.
Testing helps verify that your application behaves as expected.
13. dart test test/file_test.dart
You can also run a specific test file.
Example:
dart test test/calculator_test.dart
This allows you to run only the tests contained in that file.
14. dart pub get
Command:
dart pub get
What Does It Do?
It downloads and resolves the dependencies specified in your project’s pubspec.yaml.
For example, if your project contains dependencies, running:
dart pub get
makes those packages available to the project.
When Should You Use It?
Use it when:
- You clone an existing Dart project.
- You add or modify dependencies.
- A project asks you to install packages.
- You need to restore project dependencies.
15. dart pub add
Command:
dart pub add package_name
What Does It Do?
It adds a package to your Dart project’s dependencies.
For example:
dart pub add http
This adds the http package to the project configuration and resolves the dependency.
Why Is It Useful?
Instead of manually editing pubspec.yaml, you can use the terminal command to add a package.
16. dart pub remove
Command:
dart pub remove package_name
What Does It Do?
It removes a dependency from your Dart project.
Example:
dart pub remove http
This removes the specified package from the project’s dependencies.
17. dart pub upgrade
Command:
dart pub upgrade
What Does It Do?
It attempts to update project dependencies to newer versions allowed by the dependency constraints in your project.
For example:
dart pub upgrade
can update dependencies while respecting the version constraints defined by your project.
When Should You Use It?
Use it when you want to update your project’s resolved dependencies.
18. dart pub outdated
Command:
dart pub outdated
What Does It Do?
It helps you identify outdated dependencies in your Dart project.
It can show information about:
- Current dependency versions
- Upgradable versions
- Resolvable versions
- Latest available versions
This is useful for dependency maintenance.
19. dart pub deps
Command:
dart pub deps
What Does It Do?
It displays the dependency tree of your Dart project.
This can help you understand which packages your project depends on and which packages are included indirectly through other dependencies.
When Should You Use It?
Use it when troubleshooting dependency-related problems or trying to understand your project’s package structure.
20. dart pub cache
Dart maintains a local package cache.
You can use:
dart pub cache
to access package-cache related commands.
For more information:
dart pub cache --help
This is mainly useful when troubleshooting package installation or cache-related issues.
21. dart pub publish
Command:
dart pub publish
What Does It Do?
This command is used when publishing a Dart package to the Dart package ecosystem.
Before publishing a package, you should carefully review the package configuration and publishing requirements.
Important
Do not use this command casually on a project unless you actually intend to publish a package.
22. dart pub global
Command:
dart pub global
This command is used for managing globally activated Dart packages.
For example, Dart packages can provide command-line tools that you want to use from different projects.
You can view available options with:
dart pub global --help
23. dart pub global activate
Command:
dart pub global activate package_name
What Does It Do?
It activates a Dart package globally.
For example:
dart pub global activate package_name
The exact package name depends on the tool you want to install.
This is generally used for Dart-based command-line tools.
24. dart compile
Command:
dart compile
What Does It Do?
The dart compile command provides options for compiling Dart programs into different output formats.
You can see available compilation options using:
dart compile --help
Compilation is an advanced Dart workflow and is generally not required when you are just beginning to learn Dart.
25. dart compile exe
Command:
dart compile exe file.dart
What Does It Do?
It compiles a Dart program into a native executable.
Example:
dart compile exe bin/my_app.dart
This is useful when you want a compiled executable rather than simply running the Dart source through the standard development workflow.
26. dart compile js
Command:
dart compile js file.dart
What Does It Do?
It compiles Dart code to JavaScript where supported by the relevant Dart workflow.
This command is more relevant to specific web-related Dart use cases.
27. dart compile wasm
Modern Dart versions also provide WebAssembly-related compilation capabilities.
You can check the available options with:
dart compile wasm --help
The exact capabilities and requirements depend on your installed Dart SDK version.
28. dart fix
Command:
dart fix
What Does It Do?
The Dart fix tool can identify and apply supported automated fixes to Dart code.
To see available options:
dart fix --help
A common workflow is to preview suggested changes before applying them.
29. dart doc
Command:
dart doc
What Does It Do?
The Dart documentation tool can generate API documentation for Dart code.
This is more useful for package and library development than for beginners.
You can view available options with:
dart doc --help
30. dart info
Command:
dart info
What Does It Do?
It provides information about the Dart environment that can be useful when troubleshooting.
For example, it can help collect environment information when diagnosing setup or tooling issues.
Use:
dart info
when you need information about your Dart environment.
31. dart devtools
Command:
dart devtools
What Does It Do?
It starts Dart DevTools when the relevant tooling is available.
DevTools provides a graphical environment for inspecting and debugging applications.
This is an advanced development command and is not normally required during basic Dart installation.
32. dart run --help
Command:
dart run --help
What Does It Do?
It displays options available for the dart run command.
This is useful when you need to pass additional arguments or understand the available execution options.
33. dart pub get --help
Command:
dart pub get --help
What Does It Do?
It displays help information for the dart pub get command.
This pattern works with many Dart commands.
For example:
dart analyze --help
dart format --help
dart test --help
The --help option is one of the easiest ways to discover command-specific options.
34. where dart on Windows
This is not a Dart-specific command, but it is extremely useful when troubleshooting Dart on Windows.
where dart
What Does It Do?
It tells Windows where the dart executable is located.
For example:
C:\dart-sdk\bin\dart.exe
If multiple paths are returned, you may have multiple Dart installations.
35. which dart on macOS and Linux
On macOS and Linux, use:
which dart
What Does It Do?
It shows the Dart executable currently being used by your shell.
This is useful when checking PATH configuration.
36. echo $PATH
On macOS and Linux, you can inspect your PATH using:
echo $PATH
What Does It Do?
It displays the directories your shell searches when you enter a command.
If Dart was manually installed, this can help you determine whether its bin directory is available through PATH.
37. brew --version
If you use macOS and Homebrew, check Homebrew with:
brew --version
What Does It Do?
It displays the installed Homebrew version.
This is useful before installing Dart through Homebrew.
38. brew tap dart-lang/dart
Command:
brew tap dart-lang/dart
What Does It Do?
It adds the Dart package repository to Homebrew.
After this, Dart can be installed through the appropriate Homebrew package.
39. brew install dart
Command:
brew install dart
What Does It Do?
It installs Dart using Homebrew on macOS.
After installation, verify Dart:
dart --version
40. brew update
Command:
brew update
What Does It Do?
It updates Homebrew’s package information.
This is a Homebrew command rather than a Dart command, but it can be useful when managing a Dart installation through Homebrew.
41. brew upgrade dart
Command:
brew upgrade dart
What Does It Do?
It updates the Dart package installed through Homebrew when a newer version is available.
After upgrading, verify:
dart --version
42. sudo apt-get update
On Debian- or Ubuntu-based Linux systems:
sudo apt-get update
What Does It Do?
It refreshes package information from configured repositories.
It is commonly used before installing packages.
43. sudo apt-get install dart
Command:
sudo apt-get install dart
What Does It Do?
It installs the Dart package through APT after the appropriate Dart repository has been configured.
After installation:
dart --version
Most Important Dart Commands at a Glance
If you only want the commands you will use most frequently, keep this list handy:
dart --version
→ Check Dart SDK version
dart --help
→ Show Dart CLI help
dart create my_app
→ Create a Dart project
cd my_app
→ Enter the project directory
dart run
→ Run the project
dart run file.dart
→ Run a specific Dart file
dart analyze
→ Analyze Dart code
dart format .
→ Format Dart code
dart test
→ Run tests
dart pub get
→ Install dependencies
dart pub add package
→ Add a dependency
dart pub remove package
→ Remove a dependency
dart pub upgrade
→ Upgrade dependencies
dart pub outdated
→ Check outdated dependencies
dart pub deps
→ Display dependency tree
dart compile
→ Show compilation commands
dart fix
→ Apply supported automated fixes
dart info
→ Display Dart environment information
Dart Installation and Setup Command Flow
If you have just installed Dart and want to verify your complete setup, use this sequence.
Step 1: Check Dart
dart --version
Step 2: Find Dart
Windows:
where dart
macOS/Linux:
which dart
Step 3: Create a Project
dart create my_first_dart_app
Step 4: Enter the Project
cd my_first_dart_app
Step 5: Install Dependencies
dart pub get
Step 6: Run the Project
dart run
Step 7: Analyze the Project
dart analyze
Step 8: Format the Project
dart format .
Step 9: Run Tests
dart test
If these commands work correctly, your basic Dart environment is ready for development.
Dart Commands Cheat Sheet by Category
Installation & Environment
dart --version
dart --help
where dart
which dart
echo $PATH
dart info
Project Management
dart create project_name
cd project_name
dart run
Code Quality
dart analyze
dart format .
dart fix
Testing
dart test
Package Management
dart pub get
dart pub add package_name
dart pub remove package_name
dart pub upgrade
dart pub outdated
dart pub deps
Compilation
dart compile
dart compile exe file.dart
dart compile js file.dart
dart compile wasm --help
Documentation & Development Tools
dart doc
dart devtools
Dart Terminal Commands Cheat Sheet
Here is the compact reference you can bookmark:
| Command | Purpose |
|---|---|
dart --version | Check Dart version |
dart --help | Show Dart CLI help |
dart create app | Create a Dart project |
cd app | Open project directory |
dart run | Run project |
dart run file.dart | Run a Dart file |
dart analyze | Analyze code |
dart format . | Format project |
dart test | Run tests |
dart pub get | Get dependencies |
dart pub add package | Add package |
dart pub remove package | Remove package |
dart pub upgrade | Upgrade dependencies |
dart pub outdated | Check outdated packages |
dart pub deps | Show dependency tree |
dart compile | Access compilation commands |
dart fix | Apply supported fixes |
dart info | Show environment information |
dart doc | Generate documentation |
dart devtools | Start DevTools |
where dart | Find Dart on Windows |
which dart | Find Dart on macOS/Linux |
echo $PATH | Display PATH on macOS/Linux |
Frequently Asked Questions
What is the most important Dart terminal command?
For beginners, the most important command is:
dart --version
It verifies whether Dart is installed and available from the terminal.
Which command creates a Dart project?
Use:
dart create project_name
For example:
dart create my_app
Which command runs a Dart project?
Use:
dart run
How do I run a single Dart file?
Use:
dart run file.dart
Which command checks Dart code for errors?
Use:
dart analyze
Which command formats Dart code?
Use:
dart format .
Which command installs Dart packages?
Use:
dart pub get
How do I add a Dart package?
Use:
dart pub add package_name
How do I remove a Dart package?
Use:
dart pub remove package_name
How do I find Dart on Windows?
Use:
where dart
How do I find Dart on macOS or Linux?
Use:
which dart
Final Dart Terminal Command Reference
You do not need to memorize every Dart command immediately.
For everyday Dart development, start with these:
dart --version
dart create my_app
cd my_app
dart run
dart analyze
dart format .
dart test
dart pub get
dart pub add package_name
dart pub remove package_name
As you become more comfortable with Dart, commands such as dart pub outdated, dart pub deps, dart compile, dart fix, dart doc, and dart devtools can become useful for more advanced workflows.
The terminal is an important part of the Dart development environment. Once you understand these commands, creating projects, running applications, managing dependencies, checking code, and maintaining Dart projects becomes much faster and easier.




