How do I generate random numbers using Dart?
If you need cryptographically-secure random numbers (e.g. for encryption), and you're in a browser, you can use the DOM cryptography API:
int random() {
final ary = new Int32Array(1);
window.crypto.getRandomValues(ary);
return ary[0];
}
This works in Dartium, Chrome, and Firefox, but likely not in other browsers as this is an experimental API.