stopStepTracking method
Stops the step tracking session.
If a session is currently active and steps have been recorded, the session is saved with its start time, end time, and step count. The tracking state and related variables are reset, all data is persisted, and auto-save is stopped. An update event is emitted.
Returns true
if the operation completes successfully or if tracking was not active.
Implementation
@override
Future<bool> stopStepTracking() async {
if (!_isTracking) return true;
// Save completed session
if (_sessionSteps > 0) {
_sessions.add(StepSession(
startTime: _sessionStartTime!,
endTime: DateTime.now(),
steps: _sessionSteps,
));
}
// Reset tracking state
_isTracking = false;
_sessionSteps = 0;
_sessionStartTime = null;
_sessionStartTotalSteps = null;
_lastSavedTotalSteps = null;
await _persistAllData();
_stopAutoSave();
_emitUpdate();
return true;
}