I made cards and manage to do randomly colorize them with material Colors,
class RandomColor<Color> {
List<MaterialColor> color = [
Colors.green,
Colors.blue,
Colors.indigo,
];
var index = Random().nextInt(3);
MaterialColor colorRandomizer() {
print(color[index]);
return color[index];
}
}
Problem is when i try it with hex color, flutter gives an error "Color isn't a function"
Also the code below is working if its not in Class but it returns only 1 random color.
class RandomHexColor<Color> {
Color one = Color(0xff808000);
Color two = Color(0xff608000);
Color three = Color(0xff208080);
List<Color> hexColor = [one, two, three];
var indexColor = Random().nextInt(3);
Color colorRandom() {
print(hexColor[indexColor]);
return hexColor[indexColor];
}
}
full code can be found here https://gist.github.com/nevruzoglu/3db05f01706e5b2b4e75e24cded4a5b0