How do I generate random numbers in Dart?

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

How do I generate random numbers using Dart?

相关标签:
14条回答
  • 2021-01-31 07:31

    An alternative solution could be using the following code DRandom. This class should be used with a seed. It provides a familiar interface to what you would expect in .NET, it was ported from mono's Random.cs. This code may not be cryptography safe and has not been statistically tested.

    0 讨论(0)
  • 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));`
    
    0 讨论(0)
提交回复
热议问题