Dart version mismatch in flutter doctor and pub get - flutter

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"

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 - "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

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

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.

I have an error in vscode when trying to install flame under pubspec.yaml

I'm trying to install flame but whenever I run the pub get it gives me a really long error "Because every version of flutter_test from sdk depends on xml 3.6.1 and tiled >=0.4.0 depends on xml ^4.2.0, flutter_test from sdk is incompatible with tiled >=0.4.0." And then under it is a version solving failed error message.
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.900], locale en-US)
• Flutter version 1.17.5 at C:\Users\marci\Downloads\flutter
• Framework revision 8af6b2f038 (7 days ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
• Android SDK at C:\Users\marci\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.46.1)
• VS Code at C:\Users\marci\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.12.1
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
name: ggg
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
flame: ^0.24.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
I had the same problem today and checked on the Flame Discord channel.
They told me they have a conflict with their lib with stable flutter channel.
Recommendation is to change to Flutter Channel Beta.
I did that, then did Flutter Upgrade, then finally Flutter Pub Get and it worked.
Terminal Commands
To check which channel you are currently on
Flutter Channel
To change to the beta channel
Flutter Channel Beta
To get the beta version
Flutter Upgrade
So, when I have the same problem with you when I tried it.
Here's my solution:
In your dependencies: section inside the pubspec.yaml file, change the flame section without any version tag:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
flame:

Flutter lower dart version

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"