slot_machine 5.0.1

Slot machine #

Build Status

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 rerollContainer = querySelector("#reroll_container");
  final resultEl = querySelector("#slot_result");
  final RangeInputElement probabilityEl = querySelector("#probability");
  final probabilitySpan = querySelector("#probability_span");
  final randomButton = querySelector("#random_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(_) {
    container.children.clear();
    rerollContainer.children.clear();
    resultEl.children.clear();

    final slotMachine = new SlotMachine(probability,
        rerollable: true, rerollEffectDescription: "use coin");
    container.append(slotMachine.canvasEl);
    rerollContainer.append(slotMachine.rerollEl);
    resultEl.append(slotMachine.resultEl);
    slotMachine.play().then(print);
  }

  randomButton.onClick.listen(handle);
}

Use this package as a library

1. Depend on it

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


dependencies:
  slot_machine: ^5.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter 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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
75
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
32
Overall:
Weighted score of the above. [more]
51
Learn more about scoring.

We analyzed this package on Jan 17, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/slot_machine.dart. (-16.09 points)

Analysis of lib/slot_machine.dart reported 35 hints, including:

line 44 col 33: Unnecessary new keyword.

line 83 col 37: Unnecessary new keyword.

line 86 col 37: Unnecessary new keyword.

line 133 col 22: Use = to separate a named parameter from its default value.

line 136 col 13: Unnecessary new keyword.

Fix lib/src/precomputed_setups.dart. (-10.89 points)

Analysis of lib/src/precomputed_setups.dart reported 23 hints, including:

line 15 col 47: Avoid const keyword.

line 16 col 6: Avoid const keyword.

line 17 col 6: Avoid const keyword.

line 18 col 7: Avoid const keyword.

line 19 col 7: Avoid const keyword.

Fix bin/compute_setup.dart. (-3.93 points)

Analysis of bin/compute_setup.dart reported 8 hints, including:

line 7 col 25: Unnecessary new keyword.

line 62 col 18: Unnecessary new keyword.

line 63 col 17: Unnecessary new keyword.

line 65 col 16: Unnecessary new keyword.

line 76 col 10: Unnecessary new keyword.

Fix additional 3 files with analysis or formatting issues. (-2 points)

Additional issues in the following files:

  • lib/src/reel.dart (2 hints)
  • lib/generic_animation_frame/src/animation_frame_interface.dart (1 hint)
  • lib/generic_animation_frame/src/animation_frame_io.dart (1 hint)

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Package is getting outdated. (-48.49 points)

The package was last published 77 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <3.0.0
Dev dependencies
build_runner >=0.8.10 <0.10.0
build_web_compilers >=0.3.6 <0.5.0
test >=0.12.19 <2.0.0