The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.
Because NewsBuzz requires SDK version >=1.8.0 <2.0.0, version solving failed.
I am trying to run projects from https://startflutter.com. There are several older projects using older versions of Dart SDK or with dependencies requiring older Dart SDK version.
Is there any way to run multiple versions of Dart without downloading the older version of Dart and changing the environment variables manually?
I have gone through several StackOverflow posts and lot of Github issues without finding a proper solution.
Flutter lower dart version
Where is Dart's SDK located within /flutter folder?
Specifying SDK version in the pubspec.yaml does not seem to help.
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
Edit: Dart & Flutter support for Visual Studio Code docs says something about dart.sdkPaths and dart.flutterSdkPaths settings.
I had a similar problem:
My pubspec.yaml had the following:
environment:
sdk: ">=2.1.0 <3.0.0"
However when running flutter packages get I got the following error:
Running "flutter packages get" in xxx-app-mobile...
The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.
Because xxx_app requires SDK version >=2.1.0 <3.0.0, version solving failed.
pub get failed (1)
I tried using the exact version name as the environment variable it did not work. I tried:
flutter upgrade
flutter clean
flutter update-packages
Received the same error when running flutter packages get
I then downgraded the version requirements in the pubspec.yaml to:
environment:
sdk: ">=2.0.0 <3.0.0"
And flutter packages get worked...
So I had an app that was developed on flutter 1.x SDK's, but after my completion, I moved on to build other projects and eventually shifted to fllutter2.0
As of now, flutter downgrade only lets you go one version back, Also going back from 2.x to 1.x seems difficult
So I went to this https://docs.flutter.dev/development/tools/sdk/releases site and downloaded the version i made the app in.
Then I had my dart-sdk for that specific project changed in Android Studio
Then I did the following
Deleted .idea folder and build folder as well as pubspec-lock file.
run flutter pub get
finally flutter build apk
Now this was a dire situation so I had to resort to this
I really will not recommend this unless you are in a rough spot
Simply update you flutter sdk to latest version.
First open your command (cmd) as an adminstrator then upgrade flutter : flutter upgrade it will do everything for you
Related
On a team it is important to make sure nobody upgrades a project accidentally, or does any builds of any kind on an unexpected version of flutter, via pipeline or locally or any deployment channel.
https://github.com/passsy/flutter_wrapper/issues/30
https://github.com/flutter/website/issues/1845
You can specify the Flutter version in the pubspec.yaml file under the "environment:" section. Reference here. Here is what my pubspec.yaml looks like (notice that the line for "sdk" is the Dart version):
environment:
sdk: ">=2.17.1 <3.0.0"
flutter: 3.0.2
For example, if my local Flutter version is 3.0.1 and I specify 3.0.2, pub get outputs the following for me:
Running "flutter pub get" in my_project...
The current Flutter SDK version is 3.0.1.
Because my_project requires Flutter SDK version >=3.0.2, version solving failed.
pub get failed (1; Because my_project requires Flutter SDK version >=3.0.2, version solving failed.)
Process finished with exit code 1
But notice how the warning message says that my_project requires "greater than or equal to" instead of being pegged at precisely 3.0.2. I believe this is what Jeppe's comment refers to as an open issue.
I ran the following commands in my foo project:
iDecode#iDecodes-Mac foo % pub get
Resolving dependencies...
The current Dart SDK version is 2.7.2.
Because foo requires SDK version >=2.12.0 <3.0.0, version solving failed.
iDecode#iDecodes-Mac foo % flutter --version
Flutter 2.6.0-11.0.pre • channel dev
Tools • Dart 2.15.0 (build 2.15.0-116.0.dev)
My pubspec.yaml file has:
environment:
sdk: '>=2.12.0 <3.0.0'
As you can see my current Dart SDK version is set to 2.7.2, my project is targeting a min of 2.12.0 and Dart SDK installed on my machine is 2.15.0. So, how do I change the current Dart SDK version?
This is my ~/.zshrc file
export PATH=/flutter/bin:$PATH
export PATH=$PATH:/$HOME/Library/Android/sdk/platform-tools/
export PATH="$PATH:/$HOME/flutter/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"
export JAVA_HOME=$(/usr/libexec/java_home)
It seems like you installed Flutter/Dart SDK somewhere using Homebrew. Use which flutter and which dart to see the actual Flutter/Dart command that is taking effect. Once you find where your Dart SDK is you can use
brew uninstall dart
After this when you run which dart it will now point to where your Flutter SDK was installed.
You can also try this way:
Just download that specific flutter version from here. and just set the flutter version in your editor and try to run it will run that specific flutter version but make sure you can't run that with terminal commands. So you need to handle all commands from the Tools option.
set flutter version
Must Run commands from here
The dart version is related with flutter version, see which version is what you need here
https://docs.flutter.dev/development/tools/sdk/releases
Upgrade by running flutter upgrade [check it out here] (update dart sdk for flutter)
Flutter comes with dart by default. Suggestion is to delete old flutter, delete .zshrc and download the latest stable version 2.5.3 for your mac and then give path for it in your .zshrc. Other method is switch to flutter stable by running flutter channel stable and then give flutter upgrade command so it will catch all the stuff from git in you local machine and you'll be good to go.
Simply go to the location where Dart SDK is kept and delete that and install a new Dart SDK version from the official website which is
https://dart.dev/get-dart
I had that same issue
Resolving dependencies... (5.3s)
The current Dart SDK version is 2.17.0.
Because talk_to_me depends on browser >=0.3.1+1 which requires SDK version
<2.0.0, version solving failed
I think we need to uninstall dart and install the correct version
To uninstall dart:
sudo apt purge dart
I have an existing Flutter app that I built half a year ago. I checked on pubspec.lock, it has this line:
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.16.0 <2.0.0"
So I assume the app was built for Flutter v1.16.
How do I upgrade this app to use the latest Flutter's version? Running "flutter doctor" gives me [√] Flutter (Channel stable, 1.22.3, on Microsoft Windows [Version 10.0.19041.630], locale en-US), so my SDK is already updated to the latest version.
Interestingly, when I create a new app from scratch, the pubspec.lock does not have any information about the Flutter's version. The same section now contains only this: sdks: dart: ">=2.10.0-110 <2.11.0". In the future, how would I know which version was this app running?
I have tried running "flutter upgrade" within my app, but that was to upgrade the SDK, not the Flutter version of the app. So how do I upgrade my app to use the latest Flutter version? Or is it always built using the latest version of the SDK? Can't I target my app to build with specific version of Flutter?
To update the project to null safety follow these steps:
Side note: change the flutter version in pubsec.yaml, make new project and copy the following line:
sdk: ">=2.12.0 <3.0.0"
Then follow the steps:
Run flutter upgrade in the terminal to upgrade Flutter
Run dart migrate to run the dart migration tool.
Solve all errors which the migration tool shows.
Run flutter pub outdated --mode=null-safety to print all outdated packages.
Run flutter pub upgrade --null-safety to upgrade all packages automatically.
Check the code for errors and solve them (Very important).
Run dart migrate again and it should now be successful. Follow the link to checkout the proposed changes.
Press the "Apply Migration" button.
Check the code for errors again and fix them.
Your project should be updated now.
Referenced from this website.
Go ro the root directory of your flutter project and run flutter upgrade. This will upgrade both your existing flutter project and flutter SDK to latest version.
Run the command:
flutter upgrade
Additional for upgrading to latest stable version only
If you want to upgrade to latest version only then please first check your current flutter channel
Step 1:
Check for Stable channel
flutter channel
You will get output like this:
beta
dev
master
* stable
If output was not like this then please proceed to Step 2 or directly proceed to Step 3
Step 2:
Switch to flutter stable channel
flutter channel stable
Now you will get output like this:
beta
dev
master
* stable
Step 3:
Run the below command to upgrade to latest stable version of flutter
flutter upgrade
Inside your project root, run below command
flutter upgrade
This command will update the Flutter SDK locally installed on your workstation, wondering how does that make sense?
After you run, above command flutter upgrade the SDK is updated locally and whenever you build or run your flutter app now, it should always pick up the latest stable version (stable channel) installed locally.
to check run,
flutter channel
you should get something like below based on what version is installed locally on your workstation.
Flutter is already up to date on channel stable
Flutter 2.0.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4d7946a68d (3 days ago) • 2021-03-18 17:24:33 -0700
Engine • revision 3459eb2436
Tools • Dart 2.12.2
You can always switch to a different channel with below command,
flutter channel dev
flutter upgrade
Answer to - the Flutter SDK locally installed on your workstation, wondering how does that make sense?
Open your pubspec.yml file and see below:
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
Where version: 1.0.0+1 is your flutter app version
When you run command flutter run your app should pick up the environment as defined which is sdk: ">=2.1.0 <3.0.0"
With all dependencies as defined under,
dependencies:
flutter:
sdk: flutter
where sdk: flutter states that the SDK should be pulled from your locally installed SDK version.
Recall, how you had installed the Flutter SDK first time, on your local workstation, as below MAC example, See all SDK releases
cd ~/development
unzip ~/Downloads/flutter_macos_2.0.3-stable.zip
later, Update your path, and run flutter doctor.
OR
git clone https://github.com/flutter/flutter.git -b stable
later, Update your path, and run flutter doctor.
Note: You may check your pubspec.lock file that may look like below,
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
flutter: ">=1.16.0" <---- Use SDK greater than this installed locally
I will show you an easy way to migrate old code projects.
My recommendation is not to work on the existing old project. Instead, create a new project where you can turn your existing project code into new clean, tidy code at a time.
Now put a line of code on the existing old code project terminal as below.
$ flutter create -t <project-type> <new-project-path>
For example, your terminal code like,
PS C:\Users\habib\VScodeProject\git_ripository\simple-weather-old> flutter create -t app C:\Users\habib\VScodeProject\git_ripository\simple-weather-new
Done.
After that, Your new project will no more show any system problems, like gradle problem, android manifesto problem i.e.
If you want to see more about flutter migrating: [See this flutter doc]
if you upgrade your project, but still have problem. then please check your path spellin is ok or not!?
I also face this problem. after upgrading project it won't work for me. then i look to my code, there was miss path.
After completing all steps like SDK download, path setup in windows getting this error in flutter setup.
This error is occuring before creating flutter project.
The current Dart SDK version is 2.9.2. Because flutter_tools depends on test >=1.16.0-nullsafety which requires SDK version >=2.10.0-0 2.11.0, version solving failed. pub get failed (1; Because flutter_tools depends on test >=1.16.0-nullsafety which requires SDK version >=2.10.0-0 2.11.0, version solving failed.)
Please show your pubspec file. If you have tried all possible solutions and can't figure out the issue, I would say to try and reinstall it.
New to Flutter so sorry about the question. Tried to change the environment but project won't build.
The current Flutter SDK version is 1.9.1+hotfix.6.
Because solemaster depends on google_sign_in >=4.0.16 which requires Flutter SDK version
>=1.10.0 <2.0.0, version solving failed.
pub get failed (1)
environment:
sdk: ">=2.1.0 <3.0.0"
The flutter SDK version you're using is older than the required by the library. You're confusing the Flutter SDK with the Dart SDK. The Dark SDK is the environment on the code you provided.
google_sign_in is based on the Flutter beta channel, instead of the stable channel. (p.s. this channel is where you get your flutter updates from).
From there, you have two options:
Use an older version of google_sign_in. Version 4.0.15 or 4.0.14 should do the trick, since this change was published today as said on the changelog.
On the pubspec.yaml file, change the current declaration to google_sign_in: 4.0.15.
Change to the beta channel. Keep in mind that the Flutter versions here are being tested, so you may experience some issues. To change channel, run flutter channel beta, then flutter upgrade.
try
flutter pub cache repair
flutter clean