58

I would like to use dart SDK >= 2.2.0 with flutter. But my current version used BY Flutter is 2.1.2

flutter --version
Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8661d8aecd (2 months ago) • 2019-02-14 19:19:53 -0800
Engine • revision 3757390fa4
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

I tried to install the 2.2.0 version independently and I succeed :

dart --version
Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "macos_x64"

However, Flutter doesn't use this version as you can see above. I tried to replace files of the dart-sdk used by flutter (flutter/bin/cache/dart-sdk) by the version that I installed independently, but when I try to run Flutter after that I have a snapshot problem so I have put back the original dart-sdk folder in the flutter directory.

Do you have any ideas how can I update it?

PS: I downloaded flutter very recently (10 days ago) from here: https://flutter.dev/docs/get-started/install/macos

Itoun
  • 2,125
  • 3
  • 15
  • 34

7 Answers7

36

It might be due to the fact you are on channel stable which is the most secure builds of the four channels to get updated (channels are listed here)

If you are a bit more curious to try out the new features without having to risk bad builds I advocate channel beta:

Every month, we pick the "best" dev build of the previous month or so, and promote it to beta. These builds have been tested with our codelabs.

where the stable channel has this description:

When we believe we have a particularly good build, we promote it to the stable channel. We intend to do this more or less every quarter, but this may vary. We recommend that you use this channel for all production app releases. We may ship hotfixes to the stable channel for high-priority bugs, although our intent is to do this rarely.

You can change the channel to point at beta by running this command in your terminal: flutter channel beta followed by flutter upgrade to ensure you have got the last release for this particular branch.

Let me know how this affect your situation.

flarkmarup
  • 3,774
  • 3
  • 19
  • 20
  • 2
    It totally helped. Now my flutter dart version is 2.3.0! Thank you :) – Itoun Apr 30 '19 at 09:30
  • 11
    It's also worth mentioning that Flutter includes the Dart SDK and not to install them separately. – Patrick Kelly Nov 15 '19 at 18:45
  • thanks for sharing, searching for this issue for a long time. – Atul Chaudhary Nov 30 '19 at 03:42
  • But can we actually update the Dart SDK version and keep the current Flutter version? I have a situation where this has become a necessity. – cVergel Jan 08 '20 at 01:28
  • 1
    @cVergel, just to clarify; you want to run with a never release of the Dart SDK without upgrading the Flutter version? [This](https://stackoverflow.com/a/56100021/3266152) trick will allow you to utilize a newer Dart SDK. You must upgrade your Dart version, however. – flarkmarup Jan 09 '20 at 19:51
15

You have to upgrade flutter from cli with flutter upgrade command. Then flutter will use latest version of Dart SDK. Flutter does not use your local Dart Sdk.

11

This issue is because of the dart version and by updating flutter the dart version won't update, the way for solving this is, first, you need to be on the dev or master channel,

flutter channel master
flutter upgrade

after that run flutter doctor -v as you see your dart is still an old one

in this step, you should update it manually, as the doc says Dart

for Windows user

choco upgrade dart-sdk

for Mac users if you user brew to install dart

brew upgrade dart

and if you don't, you can install it

 brew tap dart-lang/dart
 brew install dart

wish this solves your issue.

Amit Verma
  • 6,576
  • 7
  • 29
  • 36
Ali Azimoshan
  • 165
  • 2
  • 10
1

follow some command given below :

1.flutter version -> give all the flutter version list available.

2.flutter version v1.12.13+hotfix.7 -> you can switch to any given flutter version
in your console by 1st command.

97loser
  • 776
  • 4
  • 11
1

If using windows, you can use chocolatey to upgrade sdk by using command.

choco upgrade dart-sdk

If you want the latest pre-release version:

choco upgrade dart-sdk --pre
amrit
  • 111
  • 3
  • 6
0

I have two version of flutter SDK at the same time for two different flutter projects. I had changed the current SDK to 1.12 so it was complaining about dart SDK version. I changed the current version to 1.20 and the problem solved.

RShpd
  • 916
  • 1
  • 12
  • 22
0

Yeah, the cause of the problem is inherent in the fact that Flutter does not use the dart present on your Local machine the Flutter sdk instead comes with the latest compatible dart sdk shipped along with it.

When you run the command flutter version it prints the current flutter version and the current dart-sdk version shipped along with it. If you wish to use a later version of the dart sdk you'll have to upgrade your flutter sdk and if the specific dart-sdk version you want is not yet available for any branch in the stable channel I will suggest you switch to the master or dev channel and hopefully the latest release of those channels will support the required sdk constraint you need. But beware other branches aside the stable branch are not totally safe as you can encounter strange and unresolved errors so have that at the back of your mind.