dart: The Dart command-line tool

Introduced in Dart 2.10, the dart tool (bin/dart) is a new command-line interface to the Dart SDK. The dart tool is available no matter how you get the Dart SDK — whether you explicitly download the Dart SDK or only download the Flutter SDK.

Here’s how you might use the dart tool to create, analyze, test, and run an app:

$ dart create -t console-full my_app
$ cd my_app
$ dart analyze
$ dart test
$ dart run bin/my_app.dart

You can also run pub commands using the dart tool:

$ dart pub get
$ dart pub outdated
$ dart pub upgrade

The following table shows which commands you can use with the dart tool.

Command Example of use More information
analyze dart analyze [<DIRECTORY|DART_FILE>] Analyzes the project’s Dart source code.
Use instead of dartanalyzer.
Learn more.
compile dart compile exe <DART_FILE> Compiles Dart to various formats.
Use instead of dart2js and dart2native.
Learn more.
create dart create <DIRECTORY> Creates a new project.
Use instead of stagehand.
fix dart fix <DIRECTORY|DART_FILE> Applies automated fixes to Dart source code.
Use instead of dartfix.
Learn more.
format dart format <DIRECTORY|DART_FILE> Formats Dart source code.
Use instead of dartfmt.
Learn more.
migrate dart migrate Supports migration to null safety.
Learn more.
pub dart pub <PUB_COMMAND> Works with packages.
Use instead of pub.
Learn more.
run dart run <DART_FILE> Runs a Dart program.
Use instead of the pre-existing Dart VM command.
Learn more.
test dart test [<DIRECTORY|DART_FILE>] Runs tests in this package.
Use instead of pub run test.
(none) dart <DART_FILE> Runs a Dart program, just like dart run.
Identical to the pre-existing Dart VM command.

For additional help on any of the commands, enter dart help <command> or follow the links in the More information column. You can also get details on pub commands — for example, dart help pub outdated.