Flutter – How to enable Flutter/Dart language experiments

dartflutterintellij-idea

I want to use the new spread syntax in Dart.

I'm using Android Studio for Flutter development and I receive this error.

This requires the –spread-collections experiment to be enabled

ListView(children: [...listTiles, MyWidget()])

However, I didn't find anywhere where I could specify this option.

I couldn't even make it work on the command line. flutter --spread-collections run gives Could not find an option named "spread-collections"..

flutter --version
Flutter 1.3.8 • channel beta • https://github.com/flutter/flutter.git
Framework • revision e5b1ed7a7f (4 weeks ago) • 2019-03-06 14:23:37 -0800
Engine • revision f4951df193
Tools • Dart 2.2.1 (build 2.2.1-dev.0.0 571ea80e11)

Best Answer

In my case, I have followed these two steps and It worked for me.

  1. run "flutter upgrade"

  2. changing the sdk in the environment in pubspec.yaml

    environment:
      sdk: ">=2.6.0 <3.0.0"
    
Related Topic