The current Dart SDK version is 2.15.1 in flutter - flutter

I'm getting this error for a very long time.
I tried uninstalling vs code
flutter clean
and reupdating the flutter SDK version.
even after that no success. I'm new to flutter and help me to solve the error

Highest dart version on flutters stable channel is 2.17.6 and on beta channel it is 2.18.0. To use dart SDK 2.19.something I'm guessing you'd have to step up on flutters master channel.
IF you want that, run:
flutter channel master
flutter upgrade
But why do you have such high sdk requirements in your pubspec.yaml ? Maybe this is enough? I'm thinking that it should be... so just update your pubspec.yaml file
environment:
sdk: ">=2.15.1 <3.0.0"

Related

The current Dart SDK version is 2.10.4. how can I change the version into a upper version .? In a beta or dev channel

Because classbe depends on cupertino_icons >=1.0.1 which requires SDK version >=2.12.0-0 <3.0.0, version solving failed.
Running "flutter pub get" in classbe... pub get failed (1; Because classbe depends on cupertino_icons >=1.0.1 which requires SDK version >
Update your pubspec.yaml depending on the flutter channel you want to work on:
If you are on stable channel :
environment:
sdk: ">=2.10.5 <3.0.0"
dependencies:
cupertino_icons: ^1.0.0
If you are on beta channel :
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
cupertino_icons: ^1.0.1
Then if you are on stable channel (or beta),
flutter channel stable
# or flutter channel beta
flutter upgrade
flutter pub get
flutter channel beta
flutter upgrade
You'll need to run a simple command from your terminal
flutter upgrade
If you work on Windows do the following:
Open PowerShell as Admin use
choco install dart-sdk
or to upgrade
choco upgrade dart-sdk
By default, the SDK is installed at C:\tools\dart-sdk
Than go to your IDE and check the location of your Dart SDK.
For Intellij use
File->Settings->Language & Framework->Dart->Dart SDK path
Her paste C:\tools\dart-sdk (by default)
Just upgrade your flutter
With command line:
flutter upgrade -v
My issue was different, i had changed my flutter and dart version in android studio but it was not reflecting in vs code, what I did was
I open a flutter file
at the bottom of vscode, there is a place were {} Dart is written I clicked on it and then it open up the the command palette, so I clicked on "Configure Dart language based setting"
This then open the dart configuration and I changed "dart.flutterSdkPath" to the path where my current SDK and it fixed the problem.
You can also use this for the above just download the flutter SDK you want to use to a location and follow the step I stated above

How do I upgrade an existing Flutter app?

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.

pub get failed (1; Because note requires SDK version >=1.18.0-6.0.pre <2.0.0, version solving failed.)

i am trying to use flutter SVG the latest version, but i faced a problem with my SDK version.
i changed it to what the error message said,But i still faces the same problem!
the error message is:
pub get failed (1; Because flutter_app depends on flutter_svg >=0.18.0 which requires Flutter SDK version >=1.18.0-6.0.pre <2.0.0, version solving failed.)
environment:
sdk: ">=1.18.0-6.0.pre <2.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: ^0.1.3
flutter_svg: ^0.19.1
Probably your project is created flutter beta channel or any downgrade channel. So First run:
flutter doctor -v
If your current flutter channel is beta ? then run command below:
flutter channel stable
flutter upgrade
flutter pub get
I hope solve your problem.
to upgrade your SDK do this in terminal:
flutter channel master
flutter upgrade
The channel master has the most recent build but it's not stable.
So I advise you to try flutter channel stable first.
Probably your project is created years ago.
First run flutter upgrade, then update SDK to sdk: ">=2.7.0 <3.0.0", and then pub get
I had a similar issue with a different package.
Seems like flutter_svg moved to a new flutter beta version and you are on the stable channel.
You need to use an older version of the flutter_svg package which uses an older version of flutter

Unable to add google_sign_in to flutter project, package requires older version of Flutter SDK?

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

How to run flutter projects with different/older Dart SDK dependencies?

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