by @kodeazy

flutter How to get random number up till specific range in dart file?

Home » flutter » flutter How to get random number up till specific range in dart file?
  • In this blog we will discuss on how to generate a random number uptill specific range in flutter.
  • To gnerate a random number we import dart:math which contains Random class.
  • Below is the sample program of generating a random number uptill 9.

    import 'dart:math';
    void main() {
    var rand = new Random();
    print(rand.nextInt(10));
    }

    Output:

    9