How do I generate random numbers in Dart?

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

How do I generate random numbers using Dart?

14条回答
  •  礼貌的吻别
    2021-01-31 07:22

    Here's a snippet for generating a list of random numbers

    import 'dart:math';
    
    main() {
      var rng = new Random();
      var l = new List.generate(12, (_) => rng.nextInt(100));
    }
    

    This will generate a list of 12 integers from 0 to 99 (inclusive).

提交回复
热议问题