How do I generate random numbers in Dart?

前端 未结 14 1263
一个人的身影
一个人的身影 2021-01-31 06:49

How do I generate random numbers using Dart?

14条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 07:33

    its worked for me new Random().nextInt(100); // MAX = number

    it will give 0 to 99 random number

    Eample::

    import 'dart:math';
    int MAX = 100;
    print(new Random().nextInt(MAX));`
    

提交回复
热议问题