getNextStages method

Set<String> getNextStages(
  1. List<AuthenticationFlow> flows,
  2. List<String> completed
)

Implementation

Set<String> getNextStages(
    List<AuthenticationFlow> flows, List<String> completed) {
  final nextStages = <String>{};
  for (final flow in flows) {
    // check the flow starts with the completed stages
    if (flow.stages.length >= completed.length &&
        flow.stages.take(completed.length).toSet().containsAll(completed)) {
      final stages = flow.stages.skip(completed.length);
      if (stages.isNotEmpty) nextStages.add(stages.first);
    }
  }
  return nextStages;
}