Base class for logic block states.
Inherit from this class to create a base state for a logic block. States define input handlers, lifecycle callbacks, and transitions to other states.
States are attached to a logic block when they become the active state and detached when replaced. Entrance and exit callbacks respect the state type hierarchy.
- Available extensions
Constructors
- StateLogic()
- Creates a new state logic instance, initializing internal lifecycle handler storage.
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- isAttached → bool
-
Whether this state is currently attached to a logic block context.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addError(
Object e) → void - Adds an error to the logic block. Errors are immediately processed by the logic block's LogicBlock.handleError callback.
-
async<
T> (Future< T> future) → StatefulFuture<T> - Wraps a Future so that its result is delivered as an input to the logic block. Chain StatefulFuture.input and StatefulFuture.errorInput to define which inputs to fire.
-
attach(
Context context) → void -
Attaches this state to the given
context. -
createFakeContext(
) → FakeContext - Creates and attaches a FakeContext for unit testing this state in isolation. If a fake context is already attached, it is reset and returned.
-
detach(
) → void - Detaches this state from its context.
-
enter(
[TState? previous]) → void - Runs all registered entrance callbacks for this state.
-
exit(
[TState? next]) → void - Runs all registered exit callbacks for this state.
-
get<
TData extends Object> () → TData -
Gets a value of type
TDatafrom the logic block's blackboard. -
handleInput<
TInput extends Object> (TInput input) → Transition -
Processes the given
inputthrough this state's registered input handlers and returns the resulting transition. -
input<
TInput extends Object> (TInput input) → void - Adds an input value to the logic block's internal input queue.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on<
TInput> (Func1Callback< TInput, Transition> handler) → void -
Register an input handler for inputs of type
TInput. Input instances which have the same runtime type asTInputwill be passed tohandler. Only one handler can be registered per input type — subsequent calls with the same input type will overwrite the previous handler. -
onAny(
Func1Callback< Object, Transition> handler) → void - Register a fallback handler that is called for any input that does not have a specific on handler registered. Specific handlers always take priority over onAny.
-
onEnter(
VoidCallback handler) → void -
Available on TDerived, provided by the StateLogicExtensions extension
Registers a callback invoked when entering this state type, but only if the previous state is not also of typeTDerived. -
onEnterWithPrevious(
ValueCallback< TState?> handler) → void -
Available on TDerived, provided by the StateLogicExtensions extension
Registers a callback invoked when entering this state type, receiving the previous state (ornullif there was none). Only fires if the previous state is not also of typeTDerived. -
onExit(
VoidCallback handler) → void -
Available on TDerived, provided by the StateLogicExtensions extension
Registers a callback invoked when exiting this state type, but only if the next state is not also of typeTDerived. -
onExitWithNext(
ValueCallback< TState?> handler) → void -
Available on TDerived, provided by the StateLogicExtensions extension
Registers a callback invoked when exiting this state type, receiving the next state (ornullif there is none). Only fires if the next state is not also of typeTDerived. -
output<
TOutput extends Object> (TOutput output) → void - Produces a logic block output value.
-
to<
TNextState extends TState> () → Transition -
Defines a transition to the state of type
TNextStatestored on the blackboard. -
toSelf(
) → Transition - Defines a self-transition (re-enters the current state type).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override