multiple_random_choice 0.1.3+1 copy "multiple_random_choice: ^0.1.3+1" to clipboard
multiple_random_choice: ^0.1.3+1 copied to clipboard

A function library to choose multiple items randomly. This library supports weighted randomly choosing too. Typical examples of usage are lottery and gacha.

A multiple randomly choosing function library

Features #

  • generate multiple random choice under equally probability from options
  • generate multiple random choice with weight from options

Usage / Example #

import 'package:multiple_random_choice/multiple_random_choice.dart';

// weighted multiple random choice
final m = {
  'A': 1.0,
  'B': 2.0,
  'C': 10.0,
  'D': 20,
  'E': 1,
};
final s = randomMultipleWeightedChoice<String>(m, 3, null);
print(s);
// {C,D,B}


// equally weight random multiple choice
final ss = randomMultipleChoice<String>(['A', 'B', 'C', 'D', 'E'], 2, null);
print(ss);
//ex. {C, D}

You can see more examples in example folder.

3
likes
140
pub points
69%
popularity

Publisher

verified publisherhrimfaxi-lab.com

A function library to choose multiple items randomly. This library supports weighted randomly choosing too. Typical examples of usage are lottery and gacha.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on multiple_random_choice