randomDuration static method

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.

Implementation

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