sequenceChecker method

void sequenceChecker(
  1. List<int> seq
)

Check if sequence have appeared through setting an array of bools for each number. Keeping it dynamic, so size of sequence can vary freely.

Implementation

void sequenceChecker(List<int> seq) {
  for (int i = 0; i < widget.activity.sequence.length; i++) {
    if (newNum == seq[i] && listIndexes[i] == true) {
      listIndexes[i + 1] = true;
    }
  }
  if (listIndexes[listIndexes.length - 1] == true) {
    //set all bool flags to false except first one, to restart sequencing
    seqPassed =
        true; //set flag so next press on button gives a positive result
    seqsPassed++;
    _sw.reset(); //if a new sequence passes, reset stopwatch
    _sw.start(); //timer to note delay on presssing button after seeing sequence
    for (int i = 0; i < listIndexes.length - 1; i++) {
      //reset list of bools for tracking if sequence passed
      listIndexes[i + 1] = false;
    }
  }
}