checkStroke method

void checkStroke(
  1. List<Offset?> rawStroke
)

Implementation

void checkStroke(List<Offset?> rawStroke) {
  List<Offset> stroke = getNonNullPointsFrom(rawStroke);
  final strokeLength = getLength(stroke);

  if (isQuizzing && currentStroke < nStrokes && strokeLength > 0) {
    if (strokeIsCorrect(strokeLength, stroke)) {
      notifyCorrectStrokeCallbacks();
      _summary.correctStrokePaths[currentStroke] = stroke;
      _setCurrentStroke(currentStroke + 1);

      if (currentStroke == nStrokes) {
        stopQuiz();
        notifyQuizCompleteCallbacks();
      }
    } else {
      summary.mistakes[currentStroke] += 1;
      notifyWrongStrokeCallbacks();

      if (summary.mistakes[currentStroke] >= hintAfterStrokes) {
        animateHint();
      }
    }

    notifyListeners();
  }
}