Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter --flow-control-collections are needed, but are they?

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.

 eex

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?

like image 711
William Terrill Avatar asked Dec 23 '19 16:12

William Terrill


3 Answers

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"
like image 148
Zet Avatar answered Nov 09 '22 21:11

Zet


Change dart version in pubspec.yml

environment:
  sdk: ">=2.6.0 <3.0.0"

then

 flutter pub get
 flutter clean

And restart Android Studio

like image 31
Nuts Avatar answered Nov 09 '22 19:11

Nuts


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.

like image 18
Thanooshan Avatar answered Nov 09 '22 20:11

Thanooshan