An excerpt from Dart: Up and Running

dart: The Standalone VM

You can use the dart tool (bin/dart) to run Dart command-line apps such as server-side scripts, programs, and servers. During development, you also have the option to run command-line apps using Dart Editor.

Basic Usage

Here’s an example of running a Dart file on the command line:

lang-sh
$DART_SDK/bin/dart test.dart

Options

Common command-line options for dart include:

--enable-type-checks

Check type annotations at runtime.

--assert

Evaluate assert() expressions, and terminate the program if an assertion fails.

--enable-checked-mode or --checked

Enable both assertions and type checks (checked mode).

--print-flags

Print all the command-line options.

Enabling Checked Mode

Dart programs run in one of two modes: checked or production. By default, the Dart VM runs in production mode. We recommend that you enable checked mode for development and testing.

In checked mode, assignments are dynamically checked, and certain violations of the type system raise exceptions at run time. In production mode, static type annotations have no effect.

Assert statements are also enabled in checked mode. An assert statement checks a boolean condition, raising an exception if the condition is false. Assertions do not run in production mode.

You can run the VM in checked mode with the --checked command-line flag:

lang-sh
$DART_SDK/bin/dart --checked test.dart