Skip to content

Control Flow

Durable workflows use Dart control flow for decisions and structured concurrency for concurrent awaits.

Sequential

dart
final order = await flow.serviceTask(load, input.orderId, id: 'load');
final decision = await flow.userTask(approve, order, id: 'approve');

Each id is the replay identity. Changing an id is a new operation.

Branch

dart
if (decision.approved) {
  await flow.serviceTask(publish, order, id: 'publish');
  return Result.approved();
}
return Result.rejected();

The unchosen branch is never scheduled. JSON uses switch and outcome maps on user tasks.

Parallel, Race, Quorum

See Structured Concurrency. Use these instead of Future.wait.

Fan-out

See Sagas and Fan-out for forEach. A Dart for loop over a recorded collection is also valid when each iteration's await IDs are stable.

See Also