I have a picture on the page and below it a color pallette of 9 colors. When user clicks a color from the pallette, the image is to show that color on it. For that I want to use an array and I am changing a variable on tap
selectedIndex = 0 -> 8;
And I want to pass the color in ColorFilter
child: ColorFiltered(
colorFilter: ColorFilter.mode(
Color(filters[selectedIndex]),
BlendMode.color),
child: Image('')),
I am getting an error. String is not subtype of Color. How can I do this?
This is my filters array
"Colors.black",
"Colors.blue",
"Colors.yellow",
"Colors.orange",
"Colors.pink",
"Colors.green",
"Colors.white",
"Colors.indigo",
"Colors.grey",
"Colors.red",
];
>Solution :
It expects a Color type, not a String. Remove the quotes
[
Colors.black,
Colors.blue,
Colors.yellow,
etc..
];