automata 0.2.0 copy "automata: ^0.2.0" to clipboard
automata: ^0.2.0 copied to clipboard

A dart package to create finite state machines and state charts.


Rows
Spreadsheet with superpowers!

Automata #

A dart package to create Finite State Machines and State Charts following SCXML specification.

The main highlights of automata are:

  • Declarative and type-based
  • Compound states (nested states)
  • Parallel states
  • Initial states
  • Guard conditions
  • Eventless transitions
  • Actions
  • Invoke async services
  • onEntry / onExit
  • onTransition

Documentation #

Check our wiki for a more in-depth documentation: https://github.com/rows/automata/wiki

Super quick start: #

dart pub add automata

or

flutter pub add automata
import 'package:automata/automata.dart';

class Inactive extends AutomataState {}
class Active extends AutomataState {}
class OnToggle extends AutomataEvent {}

final machine = StateMachine.create(
  (g) => g
    ..initial<Inactive>()
    ..state<Inactive>(
      builder: (g) => g..on<OnToggle, Active>()
    )
    ..state<Active>(
      builder: (g) => g..on<OnToggle, Inactive>()
    ),
  onTransition: (e, value) => print(
    '''
    ## Transition::
    Received Event: $e
    Value: $value
    ''',
  ),
);

machine.send(OnToggle());

Credits #

While developing this packages we were heavily inspired by Tinder's StateMachine, Stately's XState and the SCXML specification.

14
likes
160
points
36
downloads

Documentation

API reference

Publisher

verified publisherrows.com

Weekly Downloads

A dart package to create finite state machines and state charts.

Homepage
Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

collection, meta

More

Packages that depend on automata