matchesPreviousDocumentKey method

bool matchesPreviousDocumentKey(
  1. String? previousDocumentKey,
  2. String completedDocKey,
  3. int? completedFlowStep
)

Implementation

bool matchesPreviousDocumentKey(
  String? previousDocumentKey,
  String completedDocKey,
  int? completedFlowStep,
) {
  if (previousDocumentKey == null) return false;

  final stepTrigger = getFlowStepTrigger(previousDocumentKey);
  if (stepTrigger != null) {
    return completedFlowStep != null && completedFlowStep == stepTrigger;
  }

  if (previousDocumentKey == completedDocKey) {
    return true;
  }

  // Allow shorthand 'id' matching for identity-like sets if needed.
  if (previousDocumentKey == 'id') {
    // Example identity set matching: treat some keys as identity docs.
    const identitySet = {'id_card', 'passport', 'identity'};
    return identitySet.contains(completedDocKey);
  }

  return false;
}