randomizer_null_safe 0.1.5
randomizer_null_safe: ^0.1.5 copied to clipboard
Flutter package which helps in picking random color, random element from list, random numbers, random doubles and many more.
randomizer_null_safe #
Flutter package which helps in picking random color, random element from list, random numbers, random doubles and many more.
Fork of randomizer with null-safety, optimized code, new functions and example project.
Usage #
-
Instantiate Randomizer without seed #
Use Randomizer.instance()
to get same static instance everytime.
Randomizer randomizer = Randomizer.instance();
Randomizer randomizer2 = Randomizer.instance();
// randomizer is equal to randomizer2
copied to clipboard
This is recommended way to use Randomizer
-
Instantiate Randomizer with seed #
Use Randomizer.instance(seed)
to initiate Randomizer with your custom seed. This will also return
a different instance of Randomizer
everytime even if seed is same.
Randomizer randomizer = Randomizer.instance(N); // N is int
Randomizer randomizer2 = Randomizer.instance(O); // O may or may not be equal to N
// randomizer is not equal to randomizer2
copied to clipboard
Only use your own seed if you know what you are doing
-
Generate random color #
Color color1 = randomizer.randomColor();
Color color3 = randomizer.randomColorWithOpacity();
copied to clipboard
-
Get random value from a non-empty list #
int num = randomizer.randomElementFromList([0, 1, 2, 3]);
copied to clipboard
-
Get random integer values #
int num1 = randomizer.randomInt();
int num2 = randomizer.randomInt(max: 1000);
int num3 = randomizer.randomInt(includeNegative: true);
int num4 = randomizer.randomInt(max: 1000, includeNegative: true);
int num5 = randomizer.randomIntInRange(10000, 999999);
copied to clipboard
-
Get random double values #
double num1 = randomizer.randomDouble();
double num2 = randomizer.randomDouble(max: 99);
double num3 = randomizer.randomDouble(includeNegative: true);
double num4 = randomizer.randomDouble(max: 99, includeNegative: true);
double num5 = randomizer.randomDoubleInRange(10, 99);
copied to clipboard