weighted_random 0.2.1 copy "weighted_random: ^0.2.1" to clipboard
weighted_random: ^0.2.1 copied to clipboard

Weighted Random Algorithm for Dart libraries or applications.

Weighted Random for Dart #

Getting started #

In your flutter project add the dependency:

dependencies:
  ...
  weighted_random:

Usage #

Import weighted_random.dart

import 'package:weighted_random/weighted_random.dart';

Example using

final List<String> stringList = ["a", "b", "c", "d"];
final Map<String, dynamic> result = weightedRandom<String>(stringList, [40, 20, 60, 20]);

print(result);

Output

{item: a, index: 0}
or
{item: b, index: 1}
or
{item: c, index: 2}
or
{item: d, index: 3}

Author #

Daisuke Takayama

5
likes
140
pub points
24%
popularity

Publisher

unverified uploader

Weighted Random Algorithm for Dart libraries or applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on weighted_random