pageRoute function

List<int> pageRoute(
  1. Collection collection,
  2. Map<String, dynamic> answers
)

Implementation

List<int> pageRoute(Collection collection,Map<String,dynamic> answers){final all=_pages(collection),ids={for(var i=0;i<all.length;i++)all[i].id:i},visible=visibleAnswers(collection.questions,answers),available=<String>{},route=<int>[];var current=0;while(current<all.length){route.add(current);available.addAll(all[current].questionIds);PageBranch? branch;for(final candidate in all[current].branches){if(conditionMatches(candidate.when,available.contains(candidate.when.questionId)?visible[candidate.when.questionId]:null)){branch=candidate;break;}}current=branch==null?current+1:ids[branch.goToPageId]??all.length;}return route;}