← 返回命令列表

Linux command

dart 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Run a Dart file

dart [path/to/file.dart]

Create a new project

dart create -t [console|package|web] [project_name]

Run the project

dart run

Get package dependencies

dart pub get

Compile to a native executable

dart compile exe [bin/main.dart] -o [output]

Analyze code

dart analyze

Format Dart source code

dart format [path/to/directory]

Run tests

dart test

说明

dart is the command-line interface for the Dart programming language. It provides tools for running, compiling, testing, and managing Dart applications and packages. Dart can run programs directly in the Dart VM with JIT compilation, or compile them to native executables, JavaScript, or WebAssembly for deployment. The dart pub subcommand manages package dependencies defined in pubspec.yaml. The tool supports project templates for different application types including console applications, packages, and web applications. Code analysis and formatting tools help maintain consistent, error-free code.

参数

-h, --help
Display help information.
--version
Display the Dart SDK version.
-v, --verbose
Show additional diagnostic output.
--enable-experiment=_NAME_
Enable experimental language features.

FAQ

What is the dart command used for?

dart is the command-line interface for the Dart programming language. It provides tools for running, compiling, testing, and managing Dart applications and packages. Dart can run programs directly in the Dart VM with JIT compilation, or compile them to native executables, JavaScript, or WebAssembly for deployment. The dart pub subcommand manages package dependencies defined in pubspec.yaml. The tool supports project templates for different application types including console applications, packages, and web applications. Code analysis and formatting tools help maintain consistent, error-free code.

How do I run a basic dart example?

Run `dart [path/to/file.dart]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -h, --help do in dart?

Display help information.