RgbColor.random constructor

RgbColor.random({
  1. int minRed = 0,
  2. int maxRed = 255,
  3. int minGreen = 0,
  4. int maxGreen = 255,
  5. int minBlue = 0,
  6. int maxBlue = 255,
  7. int? seed,
})

Generates a RgbColor at random.

minRed and maxRed constrain the generated red value.

minGreen and maxGreen constrain the generated green value.

minBlue and maxBlue constrain the generated blue value.

All min and max values must be min <= max && max >= min and must be in the range of >= 0 && <= 255.

Implementation

factory RgbColor.random({
  int minRed = 0,
  int maxRed = 255,
  int minGreen = 0,
  int maxGreen = 255,
  int minBlue = 0,
  int maxBlue = 255,
  int? seed,
}) {
  assert(minRed >= 0 && minRed <= maxRed);
  assert(maxRed >= minRed && maxRed <= 255);
  assert(minGreen >= 0 && minGreen <= maxGreen);
  assert(maxGreen >= minGreen && maxGreen <= 255);
  assert(minBlue >= 0 && minBlue <= maxBlue);
  assert(maxBlue >= minBlue && maxBlue <= 255);
  return cm.RgbColor.random(
    minRed: minRed,
    maxRed: maxRed,
    minGreen: minGreen,
    maxGreen: maxGreen,
    minBlue: minBlue,
    maxBlue: maxBlue,
    seed: seed,
  ).cast();
}