I have the latest version of Flutter and I'm trying to run the official Flutter gallery app. When I do
dart --version I get
Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "macos_x64"
However, when I try to get the packages:
[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
What's interesting is when I run
flutter upgrade it lists an older version of Dart (Tools).
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)
If I understand this error correctly, Flutter is not using the latest version of Dart yet the official Flutter example app requires it. How do I fix this?
Solution 1: Günter Zöchbauer
The output of
dart --version is completely irrelevant for Flutter. What you need to check is
flutter doctor -v or
flutter --version. In your case it shows
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
You probably need to switch to another channel until the next stable channel update
flutter channel dev
flutter channel master
Solution 2: user11228247
Flutter has its own dart-sdk in
flutter/bin/cache/. So when you do
dart --version , its probably another dart sdk in your system.
Solution 3: Oliver Dixon
For anyone else stuck (The other channels were broken), what I found was switching to stable then switching versions within stable fixed it for me. You can do this by doing the following:
flutter versions 1.5.5 (Or some other version)