Skip to content

Instantly share code, notes, and snippets.

@JanrikV
Last active November 17, 2021 14:01
Show Gist options
  • Save JanrikV/8d99d2b314920b244de6ddd30760733a to your computer and use it in GitHub Desktop.
Save JanrikV/8d99d2b314920b244de6ddd30760733a to your computer and use it in GitHub Desktop.
Produce random number between two values
// 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
}
@JanrikV
Copy link
Author

JanrikV commented Nov 17, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment