State<S extends Enum> class

A state machine for tracking game/application state.

State manages transitions between enum values and provides information about recent transitions for systems that respond to state changes.

enum GameState { menu, playing, paused }

final state = State<GameState>(GameState.menu);

// Check current state
if (state.current == GameState.playing) { ... }

// Request a transition
state.set(GameState.paused);

// Apply the transition (usually done by the framework)
state.applyTransition();

Constructors

State(S _current)
Creates a state machine with the given initial state.

Properties

current → S
The current state value.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isPending → bool
Returns true if a transition is pending.
no setter
justEntered → bool
Returns true if the current state was just entered this frame.
no setter
justExited → bool
Returns true if the current state is about to exit.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

applyTransition() → void
Applies any pending state transition.
cancelTransition() → void
Clears any pending transition.
clearFlags() → void
Resets the just entered/exited flags without applying a transition.
isIn(S state) → bool
Returns true if currently in the given state.
justEnteredState(S state) → bool
Returns true if the state was just entered AND it matches the given state.
justExitedState(S state) → bool
Returns true if the state is about to exit AND it matches the given state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(S newState) → void
Requests a transition to a new state.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited