nextColor method
Generates a random Color with uniformly distributed red, green & blue values.
You can optionally specify some components of the generated Color:
red
,green
, orblue
- either
alpha
oropacity
Implementation
Color nextColor({
int? red,
int? green,
int? blue,
int? alpha,
double? opacity,
}) {
assert(
alpha == null || opacity == null,
'You cannot specify both alpha and opacity.',
);
final r = red ?? nextInt(_channelMax);
final g = green ?? nextInt(_channelMax);
final b = blue ?? nextInt(_channelMax);
if (opacity != null) return Color.fromRGBO(r, g, b, opacity);
return Color.fromARGB(alpha ?? nextInt(_channelMax), r, g, b);
}