slot_machine 3.0.1

  • README.md
  • Example
  • Installing
  • Versions
  • 14

Slot machine

A simple, self-contained class that allows user to put a simple slot machine to the DOM.

See the demo.

example/example.dart

import 'dart:html';

import 'package:slot_machine/slot_machine.dart';

void main() {
  final container = querySelector("#slot_container");
  final resultEl = querySelector("#slot_result");
  final RangeInputElement probabilityEl = querySelector("#probability");
  final probabilitySpan = querySelector("#probability_span");
  final randomButton = querySelector("#random_button");
  final successButton = querySelector("#success_button");
  final failButton = querySelector("#fail_button");

  // Allow setting up probability.
  num probability = 0.75;
  probabilityEl.onChange.listen((_) {
    probability = probabilityEl.valueAsNumber / 100;
    probabilitySpan.text = "${probabilityEl.value}%";
  });

  // Handle click of buttons.
  void handle(Result predeterminedResult) {
    container.children.clear();
    resultEl.children.clear();

    final slotMachine = new SlotMachine.fromProbability(probability,
        predeterminedResult: predeterminedResult);
    container.append(slotMachine.canvasEl);
    resultEl.append(slotMachine.resultEl);
    slotMachine.roll().then(print);
  }

  randomButton.onClick.listen((_) => handle(null));
  successButton.onClick.listen((_) => handle(Result.success));
  failButton.onClick.listen((_) => handle(Result.failure));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  slot_machine: ^3.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:slot_machine/slot_machine.dart';
  
Version Uploaded Documentation Archive
5.0.1 Jul 23, 2018 Go to the documentation of slot_machine 5.0.1 Download slot_machine 5.0.1 archive
5.0.0 Sep 24, 2017 Go to the documentation of slot_machine 5.0.0 Download slot_machine 5.0.0 archive
3.1.0 Jan 16, 2017 Go to the documentation of slot_machine 3.1.0 Download slot_machine 3.1.0 archive
3.0.1 Jan 10, 2017 Go to the documentation of slot_machine 3.0.1 Download slot_machine 3.0.1 archive
2.1.2 Jan 8, 2017 Go to the documentation of slot_machine 2.1.2 Download slot_machine 2.1.2 archive
2.1.1 Jan 8, 2017 Go to the documentation of slot_machine 2.1.1 Download slot_machine 2.1.1 archive
2.1.0 Jan 6, 2017 Go to the documentation of slot_machine 2.1.0 Download slot_machine 2.1.0 archive
2.0.1 Jan 5, 2017 Go to the documentation of slot_machine 2.0.1 Download slot_machine 2.0.1 archive
2.0.0 Jan 4, 2017 Go to the documentation of slot_machine 2.0.0 Download slot_machine 2.0.0 archive
1.0.1 Oct 1, 2014 Go to the documentation of slot_machine 1.0.1 Download slot_machine 1.0.1 archive

All 11 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
27
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
14
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0