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}');
}
6
likes
130
pub points
22%
popularity

Publisher

verified publisherj832.com

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