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:
Common command-line options for dart include:
-vfor information about all options.)
Observatory is a tool for profiling and debugging your apps. You can use the following flags to enable Observatory and to instruct the VM to delay the start up, or the exit, of an isolate:
The following is an example Observatory run:
$ dart --enable-vm-service --pause-isolates-on-exit <script>.dart
For more information, see Observatory.
You can also generate snapshots:
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 runtime. 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 --checked test.dart