TransitionHandlerBuilder<D, C> class
Provides methods for describing how a state behaves during a transition.
A TransitionHandlerBuilder is provided to the build callback provided to StateBuilder.onEnter and StateBuilder.onExit, and is used to describe the actions to take when a transition occurs within a state.
void handleExit(TransitionHandlerContext ctx) => print('State exited');
var state1 = StateKey('s1');
var builder = StateTreeBuilder(initialState: state1);
builder.state(state1, (b) {
// Post a message when the state is entered
b.onEnter((b) => b.post(message: MyMessage()));
// Run a function when the state is exited
b.onExit((b) => b.run(handleExit));
});
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
post<
M> ({FutureOr< M> getMessage(TransitionHandlerContext<D, C> ctx)?, M? message, String? label}) → void - Posts a message to be processed by the state machine when the transition occurs.
-
run(
FutureOr< void> handler(TransitionHandlerContext<D, C> ctx), {String? label}) → void -
Runs
handlerwhen the transition occurs. -
schedule<
M> ({M getMessage(TransitionHandlerContext< D, C> ctx)?, M? message, Duration duration = const Duration(), bool periodic = false, String? label}) → void - Schedules a message to be processed by the state machine when the transition occurs.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateData<
D2> (D2 update(TransitionHandlerContext< D2, C> ctx), {StateKey? stateToUpdate, String? label}) → void -
Updates ancestor state data of type
D2when the transition occurs. -
updateOwnData(
D update(TransitionHandlerContext< D, C> ctx), {String? label}) → void - Updates the state data of the handling state when the transition occurs.
-
when(
FutureOr< bool> condition(TransitionHandlerContext<D, C> ctx), void buildTrue(TransitionHandlerBuilder<D, C> builder), {String? label}) → TransitionHandlerWhenBuilder<D, C> - Describes transition behavior that may be run conditionally.
-
whenResult<
T> (FutureOr< Result< result(TransitionHandlerContext<T> >D, C> ctx), void buildSuccess(TransitionHandlerBuilder<D, T> builder), {String? label}) → TransitionHandlerWhenResultBuilder<D> -
Describes transition behavior that runs conditionally, depending on a
Resultvalue. -
whenWith<
C2> (FutureOr< C2> context(TransitionHandlerContext<D, C> ctx), FutureOr<bool> condition(TransitionHandlerContext<D, C2> ctx), void buildTrueHandler(TransitionHandlerBuilder<D, C2> builder), {String? label}) → TransitionHandlerWhenBuilder<D, C2> - Describes transition behavior that may be run conditionally, sharing a context value among conditions.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited