rand library
Random data generator for Dart.
Provides Rand, a static utility class with methods for numbers, text, names, dates, CSS colors, cryptographic tokens, and weighted samples.
Configure the global non-cryptographic RNG via Rand.useRng or Rand.seed, scope a seed to one call tree with Rand.withSeed, or inject an independent stream with RandGen. Cryptographic methods (Rand.password, Rand.nonce, Rand.bytes, Rand.base64, Rand.secureCharCode) always use Random.secure and are not affected.
import 'package:rand/rand.dart';
void main() {
Rand.seed(42);
print(Rand.fullName()); // 'Sophia Tran'
print(Rand.password()); // 12 chars, CSPRNG — not seeded
print(Rand.color()); // CssColors.rosyBrown
}
Classes
Enums
- CssColors
- CSS named colors with their ARGB values.