Skip to content

Instantly share code, notes, and snippets.

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

jasonrdsouza commented Aug 27, 2019

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