Get packages not working because of version failing - flutter

Not much to add but why would pub get fail with this error..
The current Dart SDK version is 2.9.0-14.1.beta.
Because pos_app requires SDK version >=2.9.0 <3.0.0, version solving failed.
pub get failed (1; Because pos_app requires SDK version >=2.9.0 <3.0.0, version solving failed.)
exit code 1

i had the same problem, fixed switching to flutter dev channel (in my case) and upgrading version to match the requirements.
run flutter doctor -v
you'll see that your flutter sdk version runs a dart sdk that not match the project requirements, even if you installed the latest version of dart sdk on your ide. (this made me confused)

Related

Can't pub-get from pubspec.yaml file in Flutter app

Every time I want to install a package it gives this error, how do I fix it? The error output is below:
The current Dart SDK version is 2.12.3.
The current Flutter SDK version is 0.0.0-unknown.
Because image_picker >=0.3.0 requires Flutter SDK version >=0.1.4 and image_picker <0.3.0 requires SDK version >=1.8.0 <2.0.0, image_picker is forbidden.
So, because firebase depends on image_picker any, version solving failed.
Running "flutter pub get" in firebase...
pub get failed (1; So, because firebase depends on image_picker any, version solving failed.)
You check your flutter version and check that dependency version and change the dependency version otherwise remove the version.
You have to either:
Downgrade the version of image_picker to match the flutter SDK version you currently use, or
Upgrade your flutter SDK version to a version above or equal to 1.8.0. (preferred solution).

How do i enforce all devs on a team to use the same flutter version?

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.

sdk version solving failed error on executing code

I am beginner in flutter. Doing a course from Udemy but facing lots of problems.I am making shop app.
The current Flutter SDK version is 0.0.0-unknown.
I'm getting the below error when I run it in Android Studio
Because shop_app depends on provider >=4.0.0-dev which requires
Flutter SDK version >=1.12.1, version solving failed. pub get failed
(1; Because shop_app depends on provider >=4.0.0-dev which requires
Flutter SDK version >=1.12.1, version solving failed.)

Because project requires SDK version >=2.14.0 <3.0.0, version solving failed even though Dart SDK version is 2.14.0-350.0.dev

I want to make use of typedefs for variables in Dart thus I am trying to update minimum dart version to 2.14.0.
When I change environment to
environment:
sdk: ">=2.14.0 <3.0.0"
I get the following error
[project] flutter pub get
Running "flutter pub get" in project...
The current Dart SDK version is 2.14.0-377.0.dev.
Because project requires SDK version >=2.14.0 <3.0.0, version solving failed.
pub get failed (1; Because project requires SDK version >=2.14.0 <3.0.0, version solving failed.)
exit code 1
Now I am confused what >= means if my version is 2.14.something and it does not satisfy condition >=2.14.0.
Any idea what's going on?
flutter doctor
[√] Flutter (Channel dev, 2.5.0-5.0.pre, on Microsoft Windows [Version 10.0.19043.1110], locale en-GB)
...
The version of the Dart SDK you have installed is 2.14.0-377.0.dev; the -377.0.dev part indicates that it is a development release (a pre-release), which cannot satisfy a requirement for a stable version of 2.14.0 as required by your pubspec.yaml constraints.
(Imagine that a development release introduced some new feature before some major bug was noticed and fixed. If your package depends on that feature, you probably would not want an unstable development release to satisfy your package's dependency requirement by default.)
You can set sdk: ">=2.14.0-0 <3.0.0" instead (note the -0) to indicate that you accept development versions of 2.14.0.

I am getting an error in flutter setup in android studio in windows, i already updated and having latest version of flutter and android studio

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.