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?
5
Answers
Solved: The problem is that the flutter path being used in the terminal of Android Studio was different to the flutter path in
Preferences > Languages & Frameworks > Flutter
. I found this out by typing in thewhich flutter
command, which pointed to a different flutter path.First thing I can imagine is the following.
Check Flutter and Dart settings in Settings -> Language & Frameworks -> Flutter / Dart
Make sure you use the proper flutter version and dart sdk comes from flutter/bin/cache/dart-sdk
For example my flutter is in C:flutter and the dart-sdk’s path is C:flutterbincachedart-sdk
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.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:DevFlutterTestFlutter.fvmflutter_sdk
This is critical for it to work!
check the current path of dart SDK in vscode