Skip to content

webcyou-org/dart_weighted_random

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Weighted Random Algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages