目录

Contents

获取 Dart SDK

Dart SDK 包含开发 Web、命令行和服务端应用所需要的库和命令行工具。如果你只是想开发移动应用,则不需要使用 Dart SDK,只需 安装 Flutter 即可。

The Dart SDK has the libraries and command-line tools that you need to develop Dart command-line, server, and non-Flutter web apps. To develop Flutter apps for any platform — including web and mobile apps — then instead of installing the Dart SDK, install Flutter.

要了解在 Dart 开发中你可以使用的其它工具,请查阅 Dart 工具。要了解 SDK 中的内容,请参阅 Dart SDK 概述

To learn about the tools you can use for Dart development, see the Dart tools page. To learn about what’s in the Dart SDK, see Dart SDK overview.

请查阅 Dart SDK 概览 获取更多关于 SDK 中包含哪些内容的信息。

To learn about what’s in the SDK, see Dart SDK overview.

安装 Dart SDK

Install the Dart SDK

如下所述,你可以使用包管理轻松地安装和更新 Dart SDK。你也可以以 编译 SDK 源码 的形式安装,也可以在我们的 各个发布渠道里 下载 SDK 的 zip 压缩文件

As the following instructions show, you can use a package manager to easily install and update a stable channel Dart SDK. Alternatively, you can build the SDK from source or install from any release channel by downloading the SDK as a zip file.

You can install the Dart SDK using Chocolatey.

To install the Dart SDK:

C:\> choco install dart-sdk

To upgrade the Dart SDK:

C:\> choco upgrade dart-sdk

如果您使用 64 位的 Debian/Ubuntu 系统,请选择下面任意一种方式安装,在新版本发布之后,它们都可以自动更新。

If you’re using Debian/Ubuntu on AMD64 (64-bit Intel), you can choose one of the following options, both of which can update the SDK automatically when new versions are released.

使用 apt-get 方式安装

Install using apt-get

请使用如下的方式(只需设置一次):

Perform the following one-time setup:

$ sudo apt-get update
$ sudo apt-get install apt-transport-https
$ sudo sh -c 'wget -qO- https://dl.google.com/linux/linux_signing_key.pub | apt-key add -'
$ sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'

中国的开发者,请将上面最后一行命令行的 storage.googleapis.com 替换为 storage.flutter-io.cn,如下:

Developers from China: please considering replace to the mirror site that you trusted.

$ sudo sh -c 'wget -qO- https://storage.flutter-io.cn/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'

我们尚未完整测试和保证这个镜像的稳定性,不过有任何问题,您都可以点击文档右上方进行反馈。

Note: we didn’t fully tested this mirror, it could be unstable, if you have any questions, please file an issue to us.

然后安装 Dart SDK:

Then install the Dart SDK:

$ sudo apt-get update
$ sudo apt-get install dart

使用 Debian 安装包

Install a Debian package

通过 .deb 软件包 下载 Dart SDK。

Alternatively, download Dart SDK as Debian package in the .deb package format.

在 PATH 环境变量里加入所有 Dart 二进制文件的访问

Modify PATH for access to all Dart binaries

安装 SDK 之后需要把 SDK 的 bin 目录加入你环境变量的 PATH 中去。比如,通过下面的命令可以在现有命令行窗口中加入 PATH 环境变量:

After installing the SDK, add its bin directory to your PATH. For example, use the following command to change PATH in your active terminal session:

$ export PATH="$PATH:/usr/lib/dart/bin"

为未来的命令行窗口执行永久的 PATH 环境变量设定,可以使用下面的命令:

To change the PATH for future terminal sessions, use a command like this:

$ echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.profile

Install Homebrew, and then run the following commands:

$ brew tap dart-lang/dart
$ brew install dart

To upgrade when a new release of Dart is available:

$ brew upgrade dart

To switch between locally installed Dart releases, use brew switch dart <version>. Example:

$ brew switch dart 2.8.4

To see which versions of Dart you’ve installed:

$ brew info dart

关于发行渠道和版本字符串

About release channels and version strings

Dart SDK 有三个发布渠道:

The Dart SDK has three release channels:

  • 稳定版 (Stable)渠道:稳定发行版,每 三个月 更新一次;当前版本 [calculating].

    Stable channel: stable releases, updated roughly every three months; currently [calculating].

    稳定版可适用于生产环节。

    Stable releases are suitable for production use.

  • 测试版 (Beta) 渠道:也称 发行预览版,通常 每月 更新一次;当前版本 [calculating].

    Beta channel: preview releases, usually updated every month; currently [calculating].

    测试版渠道的构建是稳定版渠道的“预览版构建”。我们推荐您使用这个渠道的 SDK、进行测试,但是不建议您的应用发布,您可以用这个渠道的构建预览新功能或测试与未来版本的兼容性。

    Beta channel builds are preview builds for the stable channel. We recommend testing, but not releasing, your apps against beta to preview new features or test compatibility with future releases.

  • 开发版 (Dev)渠道:也称 预发行版,通常每 双周 更新一次;当前版本 [calculating].

    Dev channel: prereleases, usually updated twice a week; currently [calculating].

    开发版渠道的构建包含最新的更新,也可能本身就是不完善的,这个版本我们不受支持,并且可能会包含未经审核的重大更改 (breaking changes)。

    Dev channel releases are the most current with latest changes, may be broken, are unsupported, and may contain unvetted breaking changes.

Dart SDK 稳定版 构建渠道的版本号设定为 x.y.z,比如 1.24.32.1.0。它们由点分隔的整数组成,没有连字符或字母,其中 x 是主版本,y 是次要版本,而 z 是补丁版本。

Stable channel releases of the Dart SDK have x.y.z version strings like 1.24.3 and 2.1.0. They consist of dot-separated integers, with no hyphens or letters, where x is the major version, y is the minor version, and z is the patch version.

Dart SDK 的非稳定版 (测试版 (Beta)开发版 (Dev)) 构建渠道的版本号设定为:x.y.z-a.b.<beta|dev>,比如:2.8.0-20.11.beta。连字符前的部分 (x.y.z) 遵循稳定版本方案,连字符后的 ab 分别是预发行版和预发行补丁版本,而 betadev 是构建渠道通道标示。

Beta and dev channel releases of the Dart SDK (non-stable releases) have x.y.z-a.b.<beta|dev> versions like 2.8.0-20.11.beta. The part before the hyphen follows the stable version scheme, a and b after the hyphen are the prerelease and prerelease patch versions, and beta or dev is the channel.

你可以通过 instructions above 获得 stable 和 dev 渠道,或者你也可以直接下载 SDK 的压缩包

You can get stable channel releases using the instructions above, or you can get stable, beta, or dev channel releases using a package manager or by downloading the SDK as a zip file.

你可以查阅 Dart 2 相关页面 获取更多信息。

For more information, see the Dart 2 page.