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.
Here’s an example of running a Dart file on the command
line:
$DART_SDK/bin/dart test.dart
Common command-line options for dart include:
--enable-type-checksCheck type annotations at runtime.
--assertEvaluate assert() expressions, and
terminate the program if an assertion fails.
--enable-checked-mode or
--checkedEnable both assertions and type checks
(checked mode).
--print-flagsPrint all the command-line options.
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:
$DART_SDK/bin/dart --checked test.dart