目录

Contents

Dart 的开发工具

当你准备好创建一个应用时,请根据你要创建的应用类型获取相应的 SDK 和工具。

When you’re ready to create an app, get the SDK and tools for your app type.

App type Get started instructions Tool information
应用类型 入门说明 工具信息
Mobile Install Flutter Flutter tools
移动应用 安装 Flutter Flutter 工具
Web Install the Dart SDK General-purpose tools and web tools
Web 应用 安装 Dart SDK 通用工具Web 工具
Server or command line Install the Dart SDK General-purpose tools and specialized tools
服务器或命令行应用 安装 Dart SDK 通用工具专业工具

通用工具

General-purpose tools

下述工具支持使用 Dart 语言的全部平台。

The following tools support the Dart language on all platforms.

DartPad

DartPad Hello World DartPad 是一个用于学习 Dart 语法以及体验 Dart 语言功能的在线工具。它支持 Dart 的核心库,但不支持类似 dart:io 这样的 VM 库。

DartPad Hello World DartPad is a great, no-download-required way to learn Dart syntax and to experiment with Dart language features. It supports Dart’s core libraries, except for VM libraries such as dart:io.

IDE 和编辑器

IDEs and editors

这些常用的 IDE 都带有 Dart 插件。

Dart plugins exist for these commonly used IDEs.

下面的 Dart 插件也是可用的,感谢 Dart 社区。

The following Dart plugins are also available, thanks to the Dart community.

语言服务器协议实现 同样适用于没有特定的 Dart 扩展但 支持 LSP 的编辑器

A Language Server Protocol implementation is also available for LSP-capable editors that don’t have specific Dart extensions.

命令行工具

Command-line tools

Dart SDK 中包含下面的通用工具:

The Dart SDK includes the following general-purpose tools:

dartanalyzer 命令:用于分析和报告你的代码错误或警告的静态分析器。相关 IDE 的 Dart 插件应该使用 Dart 的分析引擎,不过你依然可以从命令行运行分析器。

dartanalyzer
A static analyzer that evaluates and reports any errors or warnings in your code. The Dart plugin for your IDE should make use of Dart’s analysis engine, but you can also run the analyzer from the command line.

dartdoc 命令
生成 API 参考文档。

dartdoc
A documentation generator. For examples of dartdoc’s output, see the API reference documentation published at api.dart.dev and pub.dev (for example, the path API reference).

dartfmt 命令
根据 Dart 代码风格指南 格式化你的代码。支持 Dart 的 IDE 允许你使用它们来格式化 Dart 代码。或者你可以直接从命令行运行格式化器。

dartfmt
An opinionated code formatter that follows the recommendations of the Dart style guide. IDEs that support Dart generally allow you to format the code within the IDE. Or you can run the formatter from the command line.

pub 命令
用于管理 Dart Package 以及分享 Dart 库和命令行工具以及其它资源的工具。一些 Dart 相关的技术,比如 Flutter,可能不支持所有的 Pub 命令。支持 Dart 的 IDE 可能对 Pub 有特殊的支持方式,不过你也可以直接通过命令行使用它。

pub
A package manager that makes it easy for you to install, use, and share Dart libraries, command-line tools, and other assets. Some Dart technologies, such as Flutter, may not support all of the pub commands. IDEs that support Dart generally have special support for pub, but you can also use it from the command line.

一些额外的工具由 Package 提供。你可以通过查阅每个工具的安装介绍使用 pub 命令来安装这些工具。下面是一些你可能想要安装的通用工具:

Some additional tools are available in packages. To install these tools, use the pub command, as described in each tool’s installation instructions. Here are the general-purpose tools you might want to install:

build_runner 命令
代码生成器。

build_runner
A build package that’s used behind-the-scenes by the webdev command.

dartfix 命令:用于迁移 Dart 源代码和修复常见问题的工具。

dartfix
A tool for migrating Dart source code and fixing common issues.

调试工具

Debugging and diagnostics

Dart 开发者工具
一个工具套装帮助调试和性能测试。

Dart DevTools
A suite of suite of debugging and performance tools.

开发 Web 应用的工具

Tools for developing web apps

下面工具主要针对 Web 应用开发:

The following tools support developing web apps:

dart2js 命令
支持 Tree-shaking 的原始的 Dart-to-JavaScript 编译器。在构建用于部署的 Web 应用时,IDE 和 webdev CLI 使用 dart2js。

dart2js
The original Dart-to-JavaScript compiler, with tree shaking. IDEs and the webdev CLI use dart2js when building web apps for deployment.

dartdevc 命令
Dart dev 编译器,一个模块化的 Dart-to-Javascript 编译器。IDE 和 Webdev CLI 在运行开发服务器时会使用 dartdevc。

dartdevc
The Dart dev compiler, a modular Dart-to-JavaScript compiler. IDEs and the webdev CLI use dartdevc when running a development server.

webdev 命令:用于构建和提供 Dart Web 应用开发的命令行接口(CLI)。

webdev
A command-line interface (CLI) for Dart web app development, including building and serving web apps.

开发命令行应用和服务器的工具

Tools for developing command-line apps and servers

下面的工具对开发或运行命令行应用和服务器有特别的支持:

The following tools support developing or running command-line apps and servers:

dart 命令
独立的 Dart 虚拟机,用于执行 Dart 代码。一些支持 Dart 的 IDE 和 pub 命令使用该命令来执行 Dart 脚本。注意你必须在你的 IDE 配置中设置你的 dart 安装目录。

dart
The standalone Dart VM, which you can use to execute Dart code. IDEs that support Dart, and some of the pub commands, use this command behind-the-scenes to execute Dart scripts. Note that you must configure your IDE with the location of the dart binary.

dart2native 命令
AOT 编译器,可将 Dart 代码编译为原生 64 位机器代码。输出独立可执行文件(默认)或 AOT 快照。

dart2native
An ahead-of-time (AOT) compiler that compiles Dart code to native x64 machine code. The output is either a standalone executable (the default) or an AOT snapshot.

dartaotruntime 命令
Dart 运行时环境,可以运行 AOT 快照。

dartaotruntime
A Dart runtime that you can use to run AOT snapshots.