How do I generate random numbers in Dart?

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

How do I generate random numbers using Dart?

14条回答
  •  既然无缘
    2021-01-31 07:18

    A secure random API was just added to dart:math

    new Random.secure()
    

    dart:math Random added a secure constructor returning a cryptographically secure random generator which reads from the entropy source provided by the embedder for every generated random value.

    which delegates to window.crypto.getRandomValues() in the browser and to the OS (like urandom on the server)

提交回复
热议问题