i run flutter upgrade it works correctly but then i got errors with if used with widget
error: This requires the 'control-flow-collections' experiment to be enabled
this is my flutter version after update
i run flutter --version and this was the result
Flutter 1.17.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f7a6a7906b (9 days ago) • 2020-05-12 18:39:00 -0700
Engine • revision 6bc433c6b6
Tools • Dart 2.8.2
i need some help thank you
update your pubspec.yaml
sdk: ">=2.7.0 <3.0.0"
2.Create a file at your project root named analysis_options.yaml
3.Paste this into the newly created file
analyzer:
enable-experiment:
- spread-collections
4.Just save all and restart your editor then open terminal at your project directory and type 'flutter pub get`
Related
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
mac#MACs-MacBook-Air ChatApp % flutter pub get
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
mac#MACs-MacBook-Air ChatApp % flutter upgrade
Flutter is already up to date on channel stable
Flutter 2.0.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b1395592de (5 days ago) • 2021-04-01 14:25:01 -0700
Engine • revision 2dce47073a
Tools • Dart 2.12.2
mac#MACs-MacBook-Air ChatApp % flutter clean
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
mac#MACs-MacBook-Air ChatApp %
Execute the relevant commands in your project root directory. If you accidentally delete pubspec.yaml, create a new one.
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.
After upgrading flutter (both master and stable versions) and dart, I get an error about the experiment --flow-control-collections not being enabled for various for-loops that I'm using in the project. I tried to fix it using this entry but that just made things weirder. So, now I have the below error that tells me that I need the control-flow-collections experiement to be enabled while simultaneously telling me that it's no longer required.
This error comes up for every for-loop that I'm using.
Here's my flutter --version result:
Stable:
Flutter 1.12.13+hotfix.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 27321ebbad (13 days ago) • 2019-12-10 18:15:01 -0800
Engine • revision 2994f7e1e6
Tools • Dart 2.7.0
Master:
Flutter 1.13.6-pre.16 • channel master • https://github.com/flutter/flutter.git
Framework • revision fcaf9c4070 (2 days ago) • 2019-12-21 14:03:01 -0800
Engine • revision 33813929e3
Tools • Dart 2.8.0 (build 2.8.0-dev.0.0 886615d0f9)
Any ideas how to resolve this?
Hey, I had the same issue this morning but found a fix.
1) Keep the analysis_options.yaml in your root folder with this code:
analyzer:
enable-experiment:
- control-flow-collections
2) Don't use brackets {} in between your for loops
Ex:
<Widget>[
for (final category in categories)
CategoryWidget(category: category)
],
3) Important step which is probably why it's not working for you:
Change your Dart version constraint in the pubspec.yml file in your root folder to 2.5.2
environment:
sdk: ">=2.5.2 <3.0.0"
Change dart version in pubspec.yml
environment:
sdk: ">=2.6.0 <3.0.0"
then
flutter pub get
flutter clean
And restart Android Studio
Even after changing the dart version didn't work, then just restart your VS Code or whatever editor you're using. Then check if the error is there. If so, then run flutter clean.
I had also this issues in my project, and I resolved my issues by following this steps:
SDK: ">=2.5.2 <3.0.0"
2.Run flutter clean
3.Restart VSCode
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"