getRandomColorFromTheme function
Returns a color from a set of chosen theme colors.
Passing the same seed will yield the same color. Any object can be used as a seed.
Implementation
Color getRandomColorFromTheme(Object? seed, {List<Color>? colors}) {
final List<Color> setColors;
Object? s = seed;
if (colors == null || colors.isEmpty) {
setColors = <ui.Color>[
ZetaColorBase.red,
ZetaColorBase.orange,
ZetaColorBase.yellow,
ZetaColorBase.green,
ZetaColorBase.blue,
ZetaColorBase.teal,
ZetaColorBase.pink,
];
} else {
setColors = colors;
}
// If the Object is null (e.g. a user whose ID is null), then we always give it a set seed so the color returned is
// the same each time
s ??= 123;
return setColors[Random(s.hashCode).nextInt(setColors.length)];
}