schedule<M> method

void schedule<M>({
  1. M getMessage(
    1. TransitionContext ctx
    )?,
  2. M? message,
  3. Duration duration = const Duration(),
  4. bool periodic = false,
  5. String? label,
})

Schedules a message to be processed by the state machine when a transition occurs.

If getMessage is provided, the function will be evaluated when the scheduling occurs, and the returned message will be posted. Otherwise a message must be provided.

The scheduling will be performed using TransitionContext.schedule. Refer to that method for further details of scheduling semantics.

This action can be labeled when formatting a state tree by providing a label.

Implementation

void schedule<M>({
  M Function(TransitionContext ctx)? getMessage,
  M? message,
  Duration duration = const Duration(),
  bool periodic = false,
  String? label,
}) {
  if (getMessage == null && message == null) {
    throw ArgumentError('getValue or value must be provided');
  } else if (getMessage != null && message != null) {
    throw ArgumentError('One of getValue or value must be provided');
  }
  var _getMessage = getMessage ?? (_) => message!;
  _handler = _TransitionHandlerDescriptor.schedule<M>(_getMessage, duration, periodic, label);
}