返回介绍

Upgrading Flutter

发布于 2019-12-09 21:31:24 字数 4496 浏览 1126 评论 0 收藏 0

No matter which Flutter release channel you follow, you can use the flutter command to upgrade your Flutter SDK and the packages that your app depends on.

One-time setup

For the flutter command to work correctly, your app’s pubspec.yaml file must require the Flutter SDK. For example, the following snippet specifies that the flutter and flutter_test packages require the Flutter SDK:

name: hello_world
dependencies:
  flutter:
    sdk: flutter
dev_dependencies:
  flutter_test:
    sdk: flutter

Upgrading the Flutter SDK and packages

To update both the Flutter SDK and the packages that your app depends on, use the flutter upgrade command from the root of your app (the same directory that contains the pubspec.yaml file):

$ flutter upgrade

This command first gets the most recent version of the Flutter SDK that’s available on your Flutter channel. Then this command updates each package that your app depends on to the most recent compatible version.

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

Switching Flutter channels

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

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

Upgrading packages only

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 packages commands.

To get all the dependencies listed in the pubspec.yaml file, without unnecessary updates, use the get command:

$ flutter packages get

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

$ flutter packages upgrade

Keeping informed

We publish breaking change announcements to our mailing list. We strongly recommend that you subscribe to get announcements from us. Plus, we’d love to hear from you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文