vote 2.1.0 copy "vote: ^2.1.0" to clipboard
vote: ^2.1.0 copied to clipboard

A number of voting methods implemented in Dart with base classes that allow easy comparison between implementations.

example/example.dart

import 'package:vote/vote.dart';

void main() {
  final chocolate = 'Chocolate';
  final fudge = 'Fudge';
  final vanilla = 'Vanilla';

  final ballots = [
    for (var i = 0; i < 31; i++) RankedBallot([fudge, chocolate, vanilla]),
    for (var i = 0; i < 29; i++) RankedBallot([chocolate, fudge, vanilla]),
    for (var i = 0; i < 40; i++) RankedBallot([vanilla, chocolate, fudge]),
  ];

  final pluralityElection = PluralityElection(ballots);
  print('Plurality winner: ${pluralityElection.singleWinner}');

  final irvElection = IrvElection(ballots);
  print('IRV winner:       ${irvElection.singleWinner}');

  final condorcetElection = CondorcetElection(ballots);
  print('Condorcet winner: ${condorcetElection.singleWinner}');
}
7
likes
150
points
68
downloads

Publisher

verified publisherkevmoo.com

Weekly Downloads

A number of voting methods implemented in Dart with base classes that allow easy comparison between implementations.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

collection, graphs, meta, string_scanner

More

Packages that depend on vote