Last active
November 17, 2021 14:01
-
-
Save JanrikV/8d99d2b314920b244de6ddd30760733a to your computer and use it in GitHub Desktop.
Produce random number between two values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Produce random number between two values | |
// https://dartpad.dev/?id=8d99d2b314920b244de6ddd30760733a&null_safety=true | |
import 'dart:math'; | |
void main() { | |
random_number(min, max) { | |
final random = Random(); | |
return min + random.nextInt(max - min); | |
} | |
print(random_number(5, 20)); // Output: 9, 10, 16 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DartPad:
https://dartpad.dev/?id=8d99d2b314920b244de6ddd30760733a&null_safety=true