升级你的 Flutter 版本

无论你使用哪个 Flutter 发布渠道,你都可以使用 flutter 命令来更新 Flutter SDK 和应用所依赖的 packages。

No matter which one of the Flutter release channels you follow, you can use the flutter command to upgrade your Flutter SDK or the packages that your app depends on.

升级 Flutter SDK

Upgrading the Flutter SDK

如果要升级 Flutter SDK 的话,请使用 flutter upgrade 命令:

To update both the Flutter SDK use the flutter upgrade command:

$ flutter upgrade

这个命令首先获取你的 Flutter 渠道可用的最新的 Flutter SDK 版本。接着这个命令更新你 app 依赖的每一个 package,到最新的兼容版本。

This command gets the most recent version of the Flutter SDK that’s available on your current Flutter channel.

如果你想使用一个更加新的 Flutter SDK 版本,按照下面的步骤切换到相应的渠道 (channel),接着再运行 flutter upgrade

If you want an even more recent version of the Flutter SDK, switch to a less stable Flutter channel and then run flutter upgrade.

切换 Flutter 发布渠道

Switching Flutter channels

Flutter 有 4个发布渠道,分别是 stable, beta, dev, 和 master。我们推荐使用 stable 渠道除非你需要更加新的版本。

Flutter has four release channels: stable, beta, dev, and master. We recommend using the stable channel unless you need a more recent release.

要查看你当前使用的哪个渠道,使用下面的命令:

To view your current channel, use the following command:

$ flutter channel

要切换到其它渠道,使用 flutter channel <channel-name>。当你切换了渠道以后,使用 flutter upgrade 下载 Flutter SDK 和依赖的 packages。例如:

To change to another channel, use flutter channel <channel-name>. Once you’ve changed your channel, use flutter upgrade to download the Flutter SDK and dependent packages. For example:

$ flutter channel dev
$ flutter upgrade

仅更新 packages

Upgrading packages

如果你修改了 pubspec.yaml 文件,或者想仅更新项目依赖的 packages,而不是同时更新 packages 和 Flutter SDK,可以选择使用下面提到的 flutter pub 命令。

If you’ve modified your pubspec.yaml file, or you want to update only the packages that your app depends upon (instead of both the packages and Flutter itself), then use one of the flutter pub commands.

为了把 pubspec.yaml 文件里列出的所有依赖更新到 最新的兼容版本 ,可以使用使用 upgrade 命令:

To update to the latest compatible versions of all the dependencies listed in the pubspec.yaml file, use the upgrade command:

$ flutter pub upgrade

如果需要自动判断那些过时了的 package 依赖以及获取更新建议,现在你可以使用 outdated 命令。更多相关的信息,请参考 Dart 文档中关于 pub outdated 的说明。

To identify out-of-date package dependencies and get advice on how to update them, use the outdated command. For details, see the Dart pub outdated documentation.

$ flutter pub outdated

获得最新通知

Keeping informed

我们将在 Flutter 通知邮件列表 上发布重大更改的公告。你也可以在 Flutter 开发邮件列表 上提问!除了订阅接收公告外我们很乐意听取您的意见!

We publish breaking change announcements to the Flutter announcements mailing list. You can also ask questions on the Flutter dev mailing list. Aside from subscribing to receive announcements, we’d love to hear from you!

选择特定版本

Selecting a specific version

如果想切换到特定版本的 Flutter,你可以使用 flutter version 命令:

If you have a specific version of Flutter that you’d like to switch to, you can use the flutter version command:

$ flutter version v1.9.1+hotfix.3