Skip to content

Instantly share code, notes, and snippets.

@jasonrdsouza
Last active June 9, 2020 22:31
Embed
What would you like to do?
Dartpad Gist to Choose a Random Winner
import 'dart:math';
List<String> contestants = [
'Jason',
'Matt',
'Gabe',
'Ishan',
'Luis',
'Katie',
'Andrew',
];
String chooseWinner(List<String> contestants) {
int choice = Random.secure().nextInt(contestants.length);
return contestants[choice];
}
void main() {
print("The winner is ${chooseWinner(contestants)}");
}
@jasonrdsouza
Copy link
Author

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