randomizer_null_safe 0.1.5 copy "randomizer_null_safe: ^0.1.5" to clipboard
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 #

GitHub stars pub package

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

Screenshot #

Example

4
likes
140
points
50
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.29 - 2025.04.13

Flutter package which helps in picking random color, random element from list, random numbers, random doubles and many more.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on randomizer_null_safe