Ad

How To Display Random Number In Flutter

- 1 answer

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)];
                        });
                        }
Ad

Answer

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)];
  }
Ad
source: stackoverflow.com
Ad