Dart Version Different in Pub Runner Than `flutter --version` - flutter

Here are the results of the flutter --version command:
Flutter 2.0.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4d7946a68d (2 days ago) • 2021-03-18 17:24:33 -0700
Engine • revision 3459eb2436
Tools • Dart 2.12.2
Whenever I try to save my pubspec.yaml, I get this output:
The current Dart SDK version is 2.10.3.
...
Because adaptive_theme 2.0.0 requires SDK version >=2.12.0 <3.0.0 and no versions of adaptive_theme match >2.0.0 <3.0.0, adaptive_theme ^2.0.0 is forbidden.
I have this exact project on another computer with the same pubspec.yaml, same pubspec.lock, same flutter version. Everything is the same, but this one doesn't work.
EDIT:
Here is my environment from pubspec.yaml:
environment:
sdk: ">=2.7.0 <3.0.0"

I think the reason is that computer has Dart SDK installed with different version of Dart SDK embedded in Flutter.

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

Dart version mismatch in flutter doctor and pub get

I am trying to install package lottie: ^1.4.3 and getting following error:
The current Dart SDK version is 2.17.1 requires SDK version >=2.18.1
<3.0.0, version solving failed.
I ran flutter doctor -v and it says dart version is 2.18.1
[√] Flutter (Channel stable, 3.3.2, on Microsoft Windows [Version 10.0.19043.2006], locale en-PK)
• Flutter version 3.3.2 on channel stable at E:\Flutter\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision e3c29ec00c (12 days ago), 2022-09-14 08:46:55 -0500
• Engine revision a4ff2c53d8
• Dart version 2.18.1
• DevTools version 2.15.0
dart --version output is as follows:
Dart SDK version: 2.18.1 (stable) (Tue Sep 13 11:42:55 2022 +0200) on
"windows_x64"
I manually changed following in pubspec.yaml
environment:
sdk: ">=2.18.1 <3.0.0"
I would appreciate if someone could kindly guide me on how to resolve this. I am using Visual Studio Code as the code editor.
You should also check sub project like example folder.
the pub get will check all sub project inside the project, but it will not tell you which one.
Please replace this in pubspec.yaml file.
environment:
sdk: ">=2.16.2 <3.0.0"

Flutter - "requires SDK version >=2.18.0-271.2.beta <3.0.0, version solving failed." Error

I am getting an error like this:
The current Dart SDK version is 2.17.5.
Because exampleapp requires SDK version >=2.18.0-271.2.beta <3.0.0, version solving failed.
pub get failed (1; Because keycehennemi requires SDK version >=2.18.0-271.2.beta <3.0.0, version solving failed.)
pubspec.yaml:
environment:
sdk: '>=2.18.0-271.2.beta <3.0.0'
Exactly nek of the sdk? I do not understand. Thanks in advance for your help.
Run flutter --version to check your installed flutter and dart version
My case I am using stable version
Flutter 3.0.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f1875d570e (5 weeks ago) • 2022-07-13 11:24:16 -0700
Engine • revision e85ea0e79c
Tools • Dart 2.17.6 • DevTools 2.12.2
You can use
environment:
sdk: ">=2.17.6 <3.0.0"
You can track the version from /sdk/releases

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

Visual Studio Code Flutter Cannot Update Dart SDK

Because depends on cupertino_icons >=1.0.1 which requires SDK version >=2.12.0-0 <3.0.0, version solving failed.
whenever I tried to flutter run, flutter pub get, flutter pub upgrade, I got this return in console.. I also have tried flutter update-packages it returns
Flutter is already up to date on channel stable Flutter 1.22.5 •
channel stable • https://github.com/flutter/flutter.git Framework •
revision 7891006299 (3 weeks ago) • 2020-12-10 11:54:40 -0800 Engine
• revision ae90085a84 Tools • Dart 2.10.4
How can I update Dart SDK?
you should use 1.0.0 version of cupertino in your pubspec.yaml. I think there is a problem with new version of cupertino
cupertino_icons: ^1.0.0
As of 2021-03-10 or earlier, it is no longer necessary to use cupertino_icons 1.0.0 or switch to the beta update channel (flutter channel beta). Just upgrade (flutter upgrade) and re-run flutter pub get. For details, see issue 72231.