Skip to content

Instantly share code, notes, and snippets.

@Constans
Created January 2, 2020 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Constans/08a83c0f8683145084b3593bffcdd6c8 to your computer and use it in GitHub Desktop.
Save Constans/08a83c0f8683145084b3593bffcdd6c8 to your computer and use it in GitHub Desktop.
import 'dart:math';
class Randomizer {
num nextInRange(num a, num b) {
var rand = Random();
num result = min(a, b);
num maximum = max(a, b);
if(a is double || b is double) {
result += rand.nextDouble()*maximum;
} else {
result += rand.nextInt(maximum);
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment