Dartpad Gist to Choose a Random Winner
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
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)}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://dartpad.dev/03a14b8484f977c1a6ccabac47494baf