commitLap method

void commitLap({
  1. String? ref,
})

Resets the lap counter for ref and restarts timing from 0. Call this after the lap value has been safely captured.

Implementation

void commitLap({String? ref}) {
  ref ??= currentReference;
  if (_stopwatches.containsKey(ref)) {
    final wasRunning = _stopwatches[ref]!.isRunning;
    _stopwatches[ref]!.stop();
    _stopwatches[ref]!.reset();
    _accumulatedTime[ref] = 0;
    if (wasRunning) _stopwatches[ref]!.start();
  }
}