getTransitionsForFlow method

  1. @nonVirtual
Map<Enum, ({dynamic nextStep, ConditionFunction? preCondition})>? getTransitionsForFlow()

Returns the transition map for this flow

Implementation

@nonVirtual
Map<Enum, ({ConditionFunction? preCondition, dynamic nextStep})>?
getTransitionsForFlow() {
  __.in_('getTransitionsForFlow');
  try {
    final firstStep = getFirstStep();
    final lastStep = getLastStep();

    if (firstStep == null || lastStep == null) {
      return {}; // Or an empty map if you prefer
    }

    // Base transitions map
    final Map<Enum, ({ConditionFunction? preCondition, dynamic nextStep})>
    baseTransitions = {};

    // Only add start transition if firstStep is provided
    if (firstStep != null) {
      baseTransitions[BaseFlowStep.start] = (
        preCondition: null,
        nextStep: (_) => firstStep,
      );
    }

    // Add the special end transition handling
    baseTransitions[BaseFlowStep.end] = (preCondition: null, nextStep: null);

    // Get flow-specific transitions
    final flowTransitions = getFlowTransitions();

    // Merge transitions
    return {...baseTransitions, ...?flowTransitions};
  } catch (e, s) {
    __.severe('Failed to get transitions', e, s);
    return {}; // Return empty map instead of rethrowing
  } finally {
    __.out_('getTransitionsForFlow');
  }
}