目录

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 web, command-line, and server apps. If you’re developing only mobile apps, then you don’t need the Dart SDK; just install Flutter.

要了解在 Dart 开发中你可以使用的其它工具,请查阅 Dart 工具

To learn about other tools you can use for Dart development, see the Dart tools page.

要了解 SDK 中的内容,请参阅 Dart SDK 概述

To learn about what’s in the 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 的 zip 压缩文件 并以 编译 SDK 源码 的形式安装或更新 SDK。

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

Choose one of these options:

Install using Chocolatey

To use Chocolatey to install a stable release of the Dart SDK, run this command:

C:\> choco install dart-sdk

To install a dev release, run this command:

C:\> choco install dart-sdk --pre

To upgrade the Dart SDK, run this command (add --pre to upgrade the dev release):

C:\> choco upgrade dart-sdk

Install using a setup wizard

Alternatively, use the community-supported Dart SDK installer for Windows. You can use the wizard to install stable or dev versions of the Dart SDK.

Windows Dart Setup Wizard

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.

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-ssl.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'

Then install the stable release of the Dart SDK:

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

Or, to install the dev release of the Dart SDK, run the one-time setup commands followed by:

$ sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_unstable.list > /etc/apt/sources.list.d/dart_unstable.list'
$ sudo apt-get update
$ sudo apt-get install dart

Install a Debian package

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

Modify PATH for access to all Dart binaries

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"

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:

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

To install a dev channel release, use --devel:

$ brew install dart -- --devel

Upgrade

To upgrade when a new release of Dart is available run:

$ brew upgrade dart

To install a stable channel release when a dev release is currently active, run:

$ brew unlink dart
$ brew install dart

To upgrade to a dev channel release when a stable release is currently active, run:

$ brew upgrade --force dart -- --devel

Switch release

To switch between locally installed dart releases run brew switch dart <version>. Examples:

$ brew switch dart 1.24.3
$ brew switch dart 2.1.0

If you aren’t sure which versions of dart you have installed, then run:

$ brew info dart

The command output lists the latest stable and dev versions at the top, followed by your locally installed versions.

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

About release channels and version strings

Dart SDK 有两个发行渠道:

The Dart SDK has two release channels:

  • 稳定版渠道:稳定发行版,每六周更新一次;当前版本 [calculating].

    stable channel: stable releases, updated no more frequently than every 6 weeks; currently [calculating].

  • 开发版渠道:预览发行版,通常每周更新一次;当前版本 [calculating].

    dev channel: pre-releases, usually updated 1/week; currently [calculating].

稳定版的 Dart SDK 版本号类似 1.24.32.1.0。其由点分隔开的整数组成,并不会包含其它字符。

Stable channel releases of the Dart SDK have version strings like 1.24.3 and 2.1.0. They consist of dot-separated integers, with no hyphens or letters.

开发版的 Dart SDK(正式预览版)版本号中包含以连接符开始的其他字符。例如:Dart 2 预览发行版的版本号 2.0.0-dev.69.5 是以 2.0.0-dev 开始,并附加数字版本。

Dev channel releases of the Dart SDK (prereleases) have additional characters, starting with a hyphen (-). For example, Dart 2 prereleases have version numbers starting with 2.0.0-dev such as 2.0.0-dev.69.5.

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

You can get stable and dev channel releases using the instructions above, or you can download the SDK as a zip file.

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

For more information, see the Dart 2 page.