Random double generation between a range in dart
The nextDouble
returns a value between 0 and 1 (not included). So, if you want a number in the range a
(included) to b
(not included), you can just do:
double doubleInRange(Random source, num start, num end) =>
source.nextDouble() * (end - start) + start;
print(doubleInRange(random, a, b));
No, there isn't, but it easy to recreate it since nextInt
takes only a max
value (exclusive).
nextDouble() * max