flutter --flow-control-collections are needed, but are they?
Asked Answered
U

4

30

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?

Uptake answered 23/12, 2019 at 16:23 Comment(0)
C
69

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"
Curd answered 23/12, 2019 at 20:45 Comment(2)
Flag control-flow-collections is no longer requiredTreva
2.2.2 as min version, pub get, removing brackets of if() and restarting AndroidStudio was enough for me.Betteanne
S
31

Change dart version in pubspec.yml

environment:
  sdk: ">=2.6.0 <3.0.0"

then

 flutter pub get
 flutter clean

And restart Android Studio

Surface answered 6/4, 2020 at 14:8 Comment(0)
I
18

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.

Integrated answered 17/3, 2020 at 17:15 Comment(0)
S
1

I had also this issues in my project, and I resolved my issues by following this steps:

  1. SDK: ">=2.5.2 <3.0.0" 2.Run flutter clean 3.Restart VSCode
Supposal answered 3/5, 2021 at 10:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.