generateRandomMaterialColor function
Gets a random material design color (the color available in white text color).
If you specify ignoreColors
, you can exclude the color.
seed
can be specified.
Implementation
MaterialColor generateRandomMaterialColor({
List<Color>? ignoreColors,
int? seed,
}) {
ignoreColors ??= [];
const colors = [
Colors.pink,
Colors.red,
Colors.deepOrange,
Colors.green,
Colors.teal,
Colors.cyan,
Colors.blue,
Colors.indigo,
Colors.blue,
Colors.purple,
Colors.blueGrey,
Colors.brown,
];
return colors
.where((element) => !ignoreColors.contains(element))
.toList()
.getRandom(seed) ??
Colors.red;
}