getRandomDouble static method

double getRandomDouble(
  1. double min,
  2. double max, {
  3. bool inclusiveMin = true,
  4. bool inclusiveMax = true,
})

获取随机小数(默认包含最大最小值)

Implementation

static double getRandomDouble(double min, double max, {bool inclusiveMin = true, bool inclusiveMax = true}) {
  assert(min <= max, 'Min must be less than or equal to Max,Invalid arguments: min=$min, max=$max');
  double minVal = inclusiveMin ? min : min + 0.0000000001;
  double maxVal = inclusiveMax ? max : max - 0.0000000001;
  return minVal + Random.secure().nextDouble() * (maxVal - minVal);
}