randomDuration method Null safety

Duration randomDuration(
  1. Duration min,
  2. Duration max,
  3. [Random? random]

Generates a random Duration uniformly distributed in the range from min, inclusive, to max, exclusive.

The value of max must be larger than or equal to min. If it is equal to min, this function always returns min.

An instance of Math.Random can optionally be passed to customize the random sample distribution.


static Duration randomDuration(
  Duration min,
  Duration max, [
  Math.Random? random,
]) {
  random = random ?? Math.Random();
  return Duration(
    milliseconds: randomInt(min.inMilliseconds, max.inMilliseconds, random),