Random class

Constructors

Random()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

alpha(int length, {bool includeUppercase = false}) → String
alphaNumeric(int length, {bool includeUppercase = false}) → String
boolean() → bool
Generates a random boolean value.
coin(double probability) → bool
Returns true with the given probability (between 0.0 and 1.0).
cuid() → String
dateTime({DateTime? start, DateTime? end}) → DateTime
Generates a random DateTime between start and end.
doubleInRange(double min, double max) → double
Generates a random double in the given range min, [max).
duration({Duration min = const Duration(seconds: 0), Duration max = const Duration(seconds: 60)}) → Duration
Returns a random duration between min and max (inclusive, milliseconds).
fromCharset(int length, String charset) → String
Generates a random string from a custom charset.
hexColor({bool withAlpha = false}) → String
Generates a random color as a hex string, e.g. '#AABBCC'.
intInRange(int min, int max) → int
Generates a random int between min (inclusive) and max (exclusive).
ipv4() → String
Generates a random IP address (v4 as string).
nextDouble() → double
Returns a random double in the range [0, 1).
nextInt(int max) → int
numeric(int length) → String
pickMany<T>(List<T> values, {int? count}) → List<T>
Returns a random subset of the given values with a random size between min and max (inclusive).
pickMapValue<K, V>(Map<K, V> map, {List<double>? weights}) → V
Generates a random item from a map's values, optionally using weighted probabilities.
pickOne<T>(List<T> values) → T
Picks a random element from the given list.
pickSome<T>(List<T> values, {int? min, int? max}) → List<T>
Returns a random subset of the given values with a random size between min and max (inclusive).
shuffle<T>(List<T> values) → List<T>
Shuffles the given list and returns a new shuffled list.
uuid() → String