TransitionHandlerBuilder 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(TransactionContext 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>({M getMessage(TransitionContext ctx)?, M? message, String? label}) → void
Posts a message to be processed by the state machine when a transition occurs.
run(TransitionHandler handler, {String? label}) → void
Runs handler when the transition occurs.
schedule<M>({M getMessage(TransitionContext ctx)?, M? message, Duration duration = const Duration(), bool periodic = false, String? label}) → void
Schedules a message to be processed by the state machine when a transition occurs.
toString() String
A string representation of this object.
inherited
updateData<D>(D update(TransitionContext transCtx, D current), {StateKey? forState, String? label}) → void
Updates state data of type D when the transition occurs.
when(FutureOr<bool> condition(TransitionContext transCtx), void buildTrueHandler(TransitionHandlerBuilder), {String? label}) TransitionHandlerWhenBuilder
Indicates that a transition action should conditionally occur.

Operators

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