diff --git a/lib/src/utils/uia_request.dart b/lib/src/utils/uia_request.dart index e3a3b81f..7f1f0dff 100644 --- a/lib/src/utils/uia_request.dart +++ b/lib/src/utils/uia_request.dart @@ -102,17 +102,11 @@ class UiaRequest { List flows, List completed) { final nextStages = {}; for (final flow in flows) { - final stages = flow.stages; - final nextStage = stages[completed.length]; - var stagesValid = true; - for (var i = 0; i < completed.length; i++) { - if (stages[i] != completed[i]) { - stagesValid = false; - break; - } - } - if (stagesValid) { - nextStages.add(nextStage); + // 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;