fsm2
FMS2는 UML 상태 다이어그램의 핵심 설계 요소에 대한 Dart 구현을 제공합니다.
- 스타
- 53
- 포크
- 6
- 최근 푸시(UTC)
- 2026. 8. 16.
- 프로젝트 상태
- 활성
원본 README
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
FSM2 provides an implementation of the core design aspects of the UML2 state diagrams.
FMS2 supports:
- Nested States
- Concurrent Regions
- Guard Conditions
- sideEffects
- onEnter/onExit
- streams
- static analysis tools
- visualisation tools.
Overview
FSM2 uses a builder to delcare each state machine.
Your application may declare as many statemachines as necessary.
Example
import 'package:fsm2/fsm2.dart';
void main() {
final machine = StateMachine.create((g) => g
..initialState(Solid())
..state<Solid>((b) => b
..on<OnMelted, Liquid>(sideEffect: (e) async => print("I'm melting"))
..state<Liquid>((b) {})
));
The above examples creates a Finite State Machine (machine) which declares its initial state as being Solid and then declares a single
transition which occurs when the event OnMelted event is triggered causing a transition to a new state Liquid.
To trigger an event:
machine.applyEvent(OnMelted());
Documentation
Full documentation is available on gitbooks at:
https://fsm2.onepub.dev/
Example 2
A simple example showing the life cycle of H2O.
import 'package:fsm2/fsm2.dart';
void main() {
final machine = StateMachine.create((g) => g
..initialState(Solid())
..state<Solid>((b) => b
..on<OnMelted, Liquid>(sideEffect: (e) => print('Melted'),
)))
..state<Liquid>((b) => b
..onEnter((s, e) => print('Entering ${s.runtimeType} State'))
..onExit((s, e) => print('Exiting ${s.runtimeType} State'))
..on<OnFroze, Solid>(sideEffect: (e) => print('Frozen')))
..on<OnVaporized, Gas>(sideEffect: (e) => print('Vaporized'))))
..state<Gas>((b) => b
..on<OnCondensed, Liquid>(sideEffect: (e) => print('Condensed'))))
..onTransition((t) => print(
'Received Event ${t.event.runtimeType} in State ${t.fromState.runtimeType} transitioning to State ${t.toState.runtimeType}')));
await machine.complete;
/// machine.isInState<Hard>()
print(machine.isInSt<Solid>); // TRUE
machine.transition(OnMelted());
print(machine.isInState<Liquid>); // TRUE
machine.transition(OnFroze());
print(machine.isInState<Solid>); // TRUE
}
Credits:
FMS2 is derived from the FSM library which in turn was inspired by Tinder StateMachine library.
분류
사용 중인 의존성
프로젝트에 맞는 저장소를 선택하려면?
사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
- 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
- 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
- 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.
출처 및 관리
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗