问题
After the flutter 1.22 update, I am getting an error in Lineargradient colors property it's giving me an error that the name colors parameter isn't defined..I am getting this error everywhere in the project after the update of flutter and flutter plugin in android studio.
回答1:
Restarting your Android Studio should fix this issue.
This is because in Dart 2.10, required
becomes a keyword (previously was @required
). The IDE probably doesn't recognize that you've updated the Dart SDK.
回答2:
run flutter clean
command and restart IDE worked for me
回答3:
Run flutter clean and then restart your IDE. I use Visual Studio Code and it worked for me...
回答4:
AnimationController(vsync is not defined) when I upgraded to flutter version 1.22.3.
Flutter clean also worked for me. From any project run flutter clean and restart VS code. Everything will work fine as before.
回答5:
In my case, I did a flutter upgrade, but that did not help, I manually changed sdk to:
sdk: ">=2.10.0 <3.0.0"
Also going to File/Setting/Plugins to update the Dart and Flutter and restarted IDE as shown there solved my problem.
回答6:
Same issue(Colors is undefined for the linear gardient) happened with me after upgrading the flutter version.
Flutter clean worked for me.
Do flutter clean and restart the Visual Studio code. And It should work.
回答7:
in Lineargradient properties Change Colors: to List:
来源:https://stackoverflow.com/questions/64168427/flutter-after-flutter-1-22-update-i-am-getting-error-in-lineargradient-properti