yafsm 1.1.1 copy "yafsm: ^1.1.1" to clipboard
yafsm: ^1.1.1 copied to clipboard

Yet another Dart FSM.

example/yafsm_example.dart

import 'package:yafsm/yafsm.dart';

class SwitchMachine extends Machine {
  SwitchMachine() : super('Switch') {
    initialize(isOff);
  }

  late final isOn = state('on');
  late final isOff = state('off');
  late final turnOn = transition('turn on', {isOff}, isOn);
  late final turnOff = transition('turn off', {isOn}, isOff);
}

void main() {
  final m = SwitchMachine();
  m.start();
  print(m.isOn()); // -> false
  m.turnOn();
  print(m.isOn()); // -> true
  m.turnOff();
  print(m.isOn()); // -> false
}
1
likes
140
points
48
downloads

Publisher

verified publishermisha.jp

Weekly Downloads

Yet another Dart FSM.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on yafsm