Flutter lower dart version - flutter

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"

Related

Is the Flutter SDK Version defined anywhere in code?

I see that in the pubspec the Dart SDK version is specified/constrained but is there anywhere to specify the Flutter SDK version? Maybe I'm missing something obvious but coming from other tech stacks like Java/Gradle I believe normally SDK versions are explicit?
What got me thinking about this is that I'm using Codemagic and have my Flutter version at "default" but I can't even tell what that is from their docs or their build logs.
You can get that from your terminal just run flutter --version, this will print out your current flutter SDK and dart SDK versions.
flutter --version
the result should be similar to this
Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b06b8b2710 (2 weeks ago) • 2023-01-23 16:55:55 -0800
Engine • revision b24591ed32
Tools • Dart 2.19.0 • DevTools 2.20.1
Look like it's easy to limit it like this - I just missed it in the doc.
If I say I need ^4.0.0 then I get a meaningful error:
environment:
sdk: '>=2.18.6 <3.0.0'
flutter: ^4.0.0
Running "flutter pub get" in XXXX... Resolving
dependencies... The current Flutter SDK version is 3.7.1.
Because XXXX requires Flutter SDK version >=4.0.0, version
solving failed. pub get failed command:
"/opt/homebrew/Caskroom/flutter/3.3.10/flutter/bin/cache/dart-sdk/bin/dart
__deprecated_pub --directory . get --example" pub env: { "FLUTTER_ROOT": "/opt/homebrew/Caskroom/flutter/3.3.10/flutter",
"PUB_ENVIRONMENT": "flutter_cli:get", "PUB_CACHE":
"/Users/DENNCH3/.pub-cache", } exit code: 1

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.

Because app requires SDK version >=2.15.1 <3.0.0, version solving failed

Can anyone tell me why am I getting this error?
The current Dart SDK version is 2.12.0.
Because app requires SDK version >=2.15.1 <3.0.0, version solving failed.
pub get failed (1; Because app requires SDK version >=2.15.1 <3.0.0, version solving failed.)
here is my flutter --version
Flutter 2.10.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision db747aa133 (2 days ago) • 2022-02-09 13:57:35 -0600
Engine • revision ab46186b24
Tools • Dart 2.16.1 • DevTools 2.9.2
You should not update the dart version of this project, please open pubspec.yaml file and update
environment:
sdk: ">=2.12.0 <3.0.0"
to
environment:
sdk: ">=2.16.0 <3.0.0"
Run flutter upgrade, after run flutter pub get
I think you should update dart version, can upgrade dart version this link
like #Yasin Ege says, dart need to upgrade in order to use:
flutter channel <channel to update master or beta>
flutter upgrade
I have had the same issue.
Go to pubspec.yaml and change then make it :
environment:
sdk: '>=2.15.1 <3.0.0'
No need to upgrade flutter if you are already in the latest version. Just do this and I hope this will work.
you can resolve this error by changing :
flutter_lints: ^2.0.0 To flutter_lints: ^1.0.0 in pubspace.yaml.
flutter channel <master or beta>
flutter upgrade
But if you check dart --version is the version that matches the version the project requires and still get the error "version solving failed." like this.
flutter clean
flutter channel <master or beta>
flutter upgrade --force
When prompting your command just use flutter pub add ... instead of dart
Go pubspec.yaml and edit minimun to your dart version
From
environment:
sdk: ">=2.15.1 <3.0.0"
To
environment:
sdk: ">=2.12.0 <3.0.0"

incompatibale Dart SDK version in flutter --version and when running a project

i'm a flutter starter and currntly adding firebase authentication to my project.
i added firebase_auth and and cloud_firestore to pubspec.yaml file using command lines
flutter pub add firebase_auth
flutter pub add cloud_firestore
dependenices are
"cupertino_icons: ^1.0.2
cloud_firestore: ^2.0.0
firebase_auth: ^1.1.3"
when trying to run my project i'm getting the error
The current Dart SDK version is 2.12.0-133.2.beta.
Because firebase_auth 1.1.3 requires SDK version >=2.12.0 <3.0.0 and no versions of firebase_auth match >1.1.3 <2.0.0, firebase_auth ^1.1.3 is forbidden.
So, because elected_ones depends on firebase_auth ^1.1.3, version solving failed.
pub get failed (1; So, because elected_ones depends on firebase_auth ^1.1.3, version solving failed.)
in the error it says the Dart SDK version is 2.12.0-133.2.beta
but when i run flutter --version i get
Flutter 2.0.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1d9032c7e1 (8 days ago) • 2021-04-29 17:37:58 -0700
Engine • revision 05e680e202
Tools • Dart 2.12.3
being trying to figure it out and i got totally lost between the '''dart pub upgrade''' and '''dart pub outdated''' through transitive dependecies
problem solved by directing the IDE to correct folder where correct sdk sits
run in terminal (in project root)
flutter doctor -v
path will be shown in the first line