Reputation: 47
I need to display a random number in flutter using a function, but when i call it i get error.
void generateRandomNumber() {
setState(() {
point=pointValue[new Random().nextInt(pointValue.length)];
});
}
Upvotes: 1
Views: 627
Reputation: 34170
Return int value from your method which generated by Random
class
List<int> pointValue = [5,6,7,8,10,15];
int generateRandomNumber() {
return pointValue[new Random().nextInt(pointValue.length)];
}
Upvotes: 2