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 th
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
.
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