MessageContext class abstract
Provides information to a state about the message that is being processed.
This context is provided as an argument to TreeState.onMessage. In addition to providing access to the message that is being processed, it has several methods that allow a message handler to indicate the result its processsing. For example, the handler can indicate that a state transition should occur by calling goTo, or that message processing should be delegated to its parent state by calling unhandled.
- Available extensions
Constructors
Properties
-
activeStates
→ Iterable<
StateKey> -
The states that are currently active, starting at the active leaf state
and ending at the root.
no setter
- handlingState → StateKey
-
Identifies the active state that is currently processing a message.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- leafState → StateKey
-
Identifies the currently active leaf state.
no setter
- message → Object
-
The message that is being processed by the state machine.
no setter
-
metadata
→ Map<
String, Object> -
A map for storing application metadata.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
data<
D> (DataStateKey< D> key) → DataValue<D> -
Gets the DataValue for the active data state identified by
key. -
goTo(
StateKey targetState, {TransitionHandler? transitionAction, Object? payload, bool reenterTarget = false, Map< String, Object> metadata = const {}}) → TransitionMessageResult - Returns a MessageResult indicating that a transition to the specified state should occur.
-
goToSelf(
{TransitionHandler? transitionAction}) → TransitionMessageResult - Returns a MessageResult indicating that a self-transition should occur.
-
messageAsOrThrow<
M> () → M -
Available on MessageContext, provided by the MessageContextExtensions extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
post(
FutureOr< Object> message) → void - Posts a message that should be dispatched to the state machine asynchronously.
-
schedule(
Object message(), {Duration duration = const Duration(), bool periodic = false}) → Dispose - Schedules a message to be dispatched to the state machine asynchronously.
-
stay(
) → MessageResult - Returns a MessageResult indicating that an internal transition should occur.
-
toString(
) → String -
A string representation of this object.
inherited
-
unhandled(
) → MessageResult - Returns a MessageResult indicating the message could not be handled by a state, and that its parent state should be given an opportunity to handle the message.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited