dart: The Dart command-line tool

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

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

$ dart create -t console 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. If you're developing for Flutter, you might use the flutter tool instead.

|

CommandExample of useMore information
analyzedart analyze [<DIRECTORY|DART_FILE>]Analyzes the project's Dart source code.
Learn more.
compiledart compile exe <DART_FILE>Compiles Dart to various formats.
Replaces dart2js and dart2native.
Learn more.
createdart create <DIRECTORY>Creates a new project.
Learn more.
docdart doc <DIRECTORY>Generates API reference documentation.
Replaces dartdoc.
Learn more.
fixdart fix <DIRECTORY|DART_FILE>Applies automated fixes to Dart source code.
Learn more.
formatdart format <DIRECTORY|DART_FILE>Formats Dart source code.
Learn more.
infodart infoOutputs Dart tooling diagnostic information.
Learn more.
pubdart pub <PUB_COMMAND>Works with packages.
Replaces pub.
Learn more.
rundart run <DART_FILE>Runs a Dart program.
Replaces the pre-existing Dart VM command (dart with no command).
Learn more.
testdart test <DIRECTORY|DART_FILE>Runs tests in this package.
Replaces pub run test.
Learn more.
(none)dart <DART_FILE>Runs a Dart program; identical to the pre-existing Dart VM command.
Prefer dart run.

To get help with any of the commands, enter dart help <command>. You can also get details on pub commands.

$ dart help pub outdated