SDK in pubspec.yaml not same as in flutter --version - flutter

I'm trying to set environment sdk version to a higher number but it says that my current SDK is as seen below:
The current Dart SDK version is 2.14.4.
Because demo_app_1 requires SDK version >=2.16.0 <3.0.0, version solving failed.
pub get failed (1; Because demo_app_1 requires SDK version >=2.16.0 <3.0.0, version solving failed.)
exit code 1
When i run flutter --version i get the following:
Flutter 3.1.0-0.0.pre.854 • channel master • https://github.com/flutter/flutter.git
Framework • revision ec20ea80ad (17 hours ago) • 2022-05-21 16:28:06 -0400
Engine • revision 1bfe551d6b
Tools • Dart 2.18.0 (build 2.18.0-142.0.dev) • DevTools 2.13.1
Any help would be much appreciated. Thanks.

See you're confusing two things.
The dart SDK version that's mentioned in pubspec.yaml is for the 'dart'
version to be used in the project, not the flutter version.
Important to note that every dart version is compatible with a corresponding flutter version. The dependency can be loose though.
So in your case Flutter 3.1.0-0.0.pre.854 is the flutter version and 2.18.0 is the dart version. This shows that your flutter 3.1 is compatible with dart 2.18 and is installed, but your project uses 2.14.4
You can check the available list from flutter SDK releases

The problem is that demo_app_1 requires an SDK version >= (higher or equal) 2.16.0 but < (below) 3.0.0. The version you have installed is 3.1.0, which does not fulfill the requirement.
You have two options:
Change your flutter installation version
flutter downgrade <version>
flutter doctor
Change the required SDK version in your pubspec.yaml
Change the environment->sdk value
flutter pub get
After that, the issue should be resolved.

Run flutter downgrade 3.0.0 and check if solved

Related

Flutter SDK not matching in pubspec.yaml

I am having some errors with my flutter project as seen below.
I tried flutter upgrade, flutter clean, nothing is working to solve this issue.
Output from flutter pub get:
flutter pub get
Running "flutter pub get" in demo_app_1...
The current Dart SDK version is 2.14.4.
Because demo_app_1 depends on cloud_firestore >=3.1.10 which requires SDK version >=2.16.0 <3.0.0, version solving failed.
pub get failed (1; Because demo_app_1 depends on cloud_firestore >=3.1.10 which requires SDK version >=2.16.0 <3.0.0, version solving failed.)
exit code 1
flutter --version in terminal :
flutter --version
Flutter 3.1.0-0.0.pre.847 • channel master • https://github.com/flutter/flutter.git
Framework • revision 7459332538 (61 minutes ago) • 2022-05-21 02:33:07 -0400
Engine • revision 0264282e8b
Tools • Dart 2.18.0 (build 2.18.0-139.0.dev) • DevTools 2.13.1\
Thank you for your help.
in the pubspec.yaml you define the flutter sdk version (detailed information see here: Flutter and the pubspec file)
your importent part is the
environment:
sdk: ">=2.7.0 <3.0.0"
here you define the sdk version and like the error message says, cloud_firestore requires a SDK version between 2.16.0 and 3.0.0
so you have to adjust these version to reach the requirements

Requires SDK version >=2.16.0 <3.0.0, version solving failed

The current Dart SDK version is 2.14.4.
Because trackkit requires SDK version >=2.16.0 <3.0.0, version solving failed.
pub finished with exit code 1
My pubspec.yaml :
environment:
sdk: ">=2.16.0 <3.0.0"
after running flutter master:
Flutter is already up to date on channel master
Flutter 2.13.0-0.0.pre.145 • channel master • https://github.com/flutter/flutter.git
Framework • revision de4eb16254 (3 hours ago) • 2022-03-18 06:00:24 -0400
Engine • revision edf31ab695
Tools • Dart 2.17.0 (build 2.17.0-220.0.dev) • DevTools 2.11.4
It shows that my Dart is upgraded to 2.17.0 ? I am still unable to run!
You need to upgrade your Dart SDK with:
flutter upgrade
make sure to edit your environment in pubspec.yaml :
environment:
sdk: ">=2.16.0 <3.0.0"
This issue because of, you may installed multiple version of flutter in you system. And in android studio tools pointed to lower version of flutter location.
First you update flutter.
Then check flutter version. flutter --version Make sure you are upgraded to your specified version.
Then check the location of the framework using which flutter
Then you will get the path like /Applications/flutter/bin/flutter
Then open android studio (in mac) go to android studio preference.
Go to Languages & Frameworks from left menu.
Select flutter under the languages &framework section.
Add correct SDK path under flutter SDK path like - /Applications/flutter
If you add correct SDK path it will show the upgraded version and channel details below of the path.
Then click to apply and ok.
It will solve your issue.

problem with dart-sdk from within flutter

I run flutter upgrade and and I got the following message
C:\Users\lenovo\IdeaProjects\simple>flutter upgrade
Flutter is already up to date on channel stable
Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 18116933e7 (3 weeks ago) • 2021-10-15 10:46:35 -0700
Engine • revision d3ea636dc5
Tools • Dart 2.14.4
but when I try to upgrade the packages including the riverpod which has got to the stable release today
I got the following message
The current Dart SDK version is 2.13.4.
Because simple depends on flutter_riverpod >=1.0.0 which requires SDK version >=2.14.0 <3.0.0, version solving failed.
pub get failed (1; Because simple depends on flutter_riverpod >=1.0.0 which requires SDK version >=2.14.0 <3.0.0, version solving failed.)
I when check the dart sdk in the setting of the editor I'm currently using, the dart sdk is of version 2.13.4
anyone know how to fix this issue ??
Try removing the versions, keep only the dependency names in pubspec.yaml . Then run flutter pub get. It will automatically download all compatible versions.

is it possible to continue using flutter SDK "1.20.0" and not upgrading anymore? any future problems can arise from that behavior?

every time i get a notification to upgrade to newer flutter SDK and i do the upgrade...my project gets broken...due to incompatibility of packages with each others...i tried to install the packages again one by one...also tried to manipulate the packages version...i tried to migrate to different flutter channels like master, dev, beta..going back to stable...but no luck :(
and i end up in downgrading the flutter SDK to "1.20.0" again...i did that everytime till the newest version of flutter SDK "1.22.4 1aafb3a 13/11/2020"
once i downgrade to "1.20.0"..everything goes fine...
for example...one of the errors am facing right now using the flutter SDK "1.22.4"..when i flutter pub get..i get this:
Because every version of flutter_common_exports depends on flutter_localizations any from sdk which depends on collection 1.15.0-nullsafety.3, every version of flutter_common_exports requires collection 1.15.0-nullsafety.3.
And because dartx >=0.2.0 <0.5.0 depends on collection >=1.14.11 <1.15.0, flutter_common_exports is incompatible with dartx >=0.2.0 <0.5.0.
So, because myApp depends on flutter_common_exports any which depends on dartx ^0.4.1, version solving failed.
pub get failed (1; So, because myApp depends on flutter_common_exports any which depends on dartx ^0.4.1, version solving failed.)
exit code 1
am using:
Flutter 1.22.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1aafb3a8b9 (28 hours ago) • 2020-11-13 09:59:28 -0800
Engine • revision 2c956a31c0
Tools • Dart 2.10.4
so what will happen if i didn't follow any upgrade notifications and continue developing my app using flutter SDK "1.20.0" till i release my app to the store ?!
is there any consequences that will happen?!
thanks in advance
In short, you can’t use the latest SDK on this project yet, not while the packages you’re using don’t get updated and are compatible with the latest SDK.
You can use the old SDK, you're just missing out on new features.
If you work with a team, you should start declaring the compatible SDK on your “pubspec.yaml” file, so that everyone knows which SDK version it was tested for:
version: 1.0.0+1
environment:
sdk: ">=2.2.2 <3.0.0"
flutter: "1.9.1+hotfix.6"

Flutter lower dart version

I'm getting the following error due to Dart version of my flutter setup when I run the flutter get packages command:
[project_name] flutter packages get Running "flutter packages get"
in project_name...
The current Dart SDK version is
2.1.0-dev.0.0.flutter-be6309690f.
Because project depends on intl_translation >=0.14.0+1 <0.17.0 which
requires SDK version >=1.12.0 <2.0.0, version solving failed. pub get
failed (1) exit code 1
My framework version:
Flutter 0.6.0 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 9299c02cf7 (2 weeks ago) • 2018-08-16 00:35:12 +0200
Engine • revision e3687f70c7
Tools • Dart 2.1.0-dev.0.0.flutter-be6309690f
I would like to learn if there's some kind of command to lower dart-sdk version of the flutter framework, thanks in advance.
In the Flutter install directory execute
git checkout v"0.5.0" // for example
You can check which versions are available in the Flutter GitHub repository https://github.com/flutter/flutter
You can only change the Dart version if you change to a Flutter version that contains the desired Dart version.
Change the dependency to
dev_dependencies:
intl_translations: ^0.17.0
Add following dependency in pubspec.yaml file
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"