Flutter says Dart version is 2.13.4 even though it's 2.16.0
Solution 1
Look for the sdk setting in your project's pubspec.yaml
file. This is what determines the minimum Dart SDK version for you project. Change to lower bound to 2.14.0.
environment:
sdk: ">=2.14.0 <3.0.0"
Solution 2
If you are using FVM, make sure you point the Flutter SDK path to the symbolic link folder in your project, that then references the latest active Flutter sdk version
Something like: C:\Dev\Flutter\TestFlutter\.fvm\flutter_sdk
This is critical for it to work!
Zorgan
Updated on January 02, 2023Comments
-
Zorgan over 1 year
I'm trying to install this http package to my flutter app.
But when i perform
flutter pub get
I get this error:The current Dart SDK version is 2.13.4. Because http 0.13.4 requires SDK version >=2.14.0 <3.0.0 and no versions of http match >0.13.4 <0.14.0, http ^0.13.4 is forbidden. So, because app depends on http ^0.13.4, version solving failed. pub get failed (1; So, because spotlight depends on http ^0.13.4, version solving failed.)
However I performed
flutter upgrade
before this and it says i'm on the latest version which includes Dart.Flutter is already up to date on channel master Flutter 2.9.0-1.0.pre.198 • channel master • https://github.com/flutter/flutter.git Framework • revision 3f775d864e (11 hours ago) • 2021-12-26 08:59:07 -0500 Engine • revision d56b72b117 Tools • Dart 2.16.0 (build 2.16.0-135.0.dev) • DevTools 2.9.2
Why is this?
Edit:
pubspec.yaml
below:name: app description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 http: ^0.13.4 dev_dependencies: flutter_test: sdk: flutter
In my settings it says
2.13.4
:EDIT: So the problem is the Flutter path is incorrect when I type
which flutter
. It is different from my path in Android Studio. How can I change this?-
jamesdlin over 2 yearsYou haven't shown your
pubspec.yaml
file. Does it specify a minimum Dart SDK version of 2.14.0 or higher? -
Mahesh Jamdade over 2 yearsWould you mind sharing your pubspec.yaml?
-
Zorgan over 2 yearsHi both I have shared my
pubspec.yaml
in the edit. Changing the environment sdk tosdk: ">=2.14.0 <3.0.0"
still returns the same error after runningpub get
. -
Zorgan over 2 yearsJust checked my settings under Languages & Frameworks and it says
2.13.4
- added screenshot in edit
-
-
Zorgan over 2 yearsI did this, then ran
pub get
but still returned the same error. -
Zorgan over 2 yearsJust checked my settings under Languages & Frameworks and it says
2.13.4
- added screenshot in edit -
Christopher Moore over 2 years@Zorgan Restart your IDE and make sure the flutter executable you added to your path is the same as what you see in your screenshot.
-
Zorgan over 2 yearsYes the dark sdk comes from
/flutter/bin/cache/dart-sdk
- however if you check my edit it shows a screenshot with an old version that can't be upgraded -
Zorgan over 2 yearsI have restarted the IDE and the path is correct. Flutter path:
/Users/jameskrousorati/Documents/flutter
& Dart path is:/Users/jameskrousorati/Documents/flutter/bin/cache/dart-sdk