Home > database >  when identifying an variable color in the class and I cant use it in flutter
when identifying an variable color in the class and I cant use it in flutter

Time:03-26

when identifying an variable color in the class and I cant use it in flutter what's the the wrong?

backColor error

when identifying an variable color in the class and I cant use it in flutter what's the the wrong?

backColor error

CodePudding user response:

Colors.white is a type of MaterialColor not Color.

Change your variable declaration to MaterialColor backColor = Colors.white, or even better, just write final backColor = Colors.white.

CodePudding user response:

There's a key difference between a materialColor and Color..

https://elifent.tech/blog/what-is-difference-between-materialcolor-and-color-in-flutter

change your variable to: Color backColor = const Color(0xFFFFFFFF);

have a read.. do upvote if helpful

  • Related