reset method

void reset({
  1. Duration? duration,
})

Resets the scratcher state to the initial values.

Implementation

void reset({Duration? duration}) {
  setState(() {
    transitionDuration = duration;
    isFinished = false;
    canScratch = duration == null;
    thresholdReported = false;

    _lastPosition = null;
    points = [];
    checked = {};
    progress = 0;
    progressReported = 0;
  });

  // Do not allow to scratch during transition
  if (duration != null) {
    Future.delayed(duration, () {
      setState(() {
        canScratch = true;
      });
    });
  }

  _setCheckpoints(_renderObject!.size);
  widget.onChange?.call(0);
}