Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

apply shade to flutter color variable

I have defined a variable that holds a color value and when I setstate the screen, I always change this color. I want to use this color both as normal and shade100 in my application. However, my code is giving an error below.

late Color objeColor;
objeColor = Colors.orange;

Container(
   decoration: BoxDecoration(
   shape: BoxShape.circle,
   color: objeColor, // there is no error *******
   ),),


Container(
   decoration: BoxDecoration(
   shape: BoxShape.circle,
   color: objeColor.shade100, // there is error *******
),),

error

The getter ‘shade100’ isn’t defined for the type ‘Color’.
Try importing the library that defines ‘shade100’, correcting the name to the name of an existing getter, or defining a getter or field named ‘shade100’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

shade100 is a getter for MaterialColor. You can do

 late MaterialColor objeColor;
 ...
 color: objeColor.shade100 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading