我拥有最新版本的Flutter,并且我正在尝试运行官方的Flutter Gallery应用。当我做dart --version
时,我得到
Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "macos_x64"
但是,当我尝试获取软件包时:
[flutter_gallery] flutter packages get
Running "flutter packages get" in flutter_gallery...
The current Dart SDK version is 2.1.2-dev.0.0.flutter-0a7dcf17eb.
Because flutter_gallery requires SDK version >=2.2.0 <3.0.0, version solving failed.
pub get failed (1)
exit code 1
有趣的是,当我运行flutter upgrade
时,它列出了较旧版本的Dart(工具)。
Upgrading Flutter from /Users/leejohnson/dev/flutter...
From https://github.com/flutter/flutter
a1bee54fd..59ce7d6bf dev -> origin/dev
55a2ee588..f8f2b043e master -> origin/master
* [new tag] v1.3.13 -> v1.3.13
Already up to date.
Upgrading engine...
Already up-to-date.
Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8661d8aecd (5 weeks ago) • 2019-02-14 19:19:53 -0800
Engine • revision 3757390fa4
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
如果我正确理解此错误,则Flutter没有使用最新版本的Dart,但Flutter官方示例应用程序需要它。我该如何解决?
答案 0 :(得分:7)
dart --version
的输出与Flutter完全无关。您需要检查的是flutter doctor -v
或flutter --version
。您的情况显示为Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
您可能需要切换到另一个频道,直到下一个稳定的频道更新
flutter channel dev
或
flutter channel master
答案 1 :(得分:2)
答案 2 :(得分:0)
对于陷入困境的其他人(其他渠道已中断),我发现正在切换到稳定版,然后在稳定版中切换版本对我来说是固定的。您可以执行以下操作:
flutter versions
flutter versions 1.5.5
(或其他版本)