recordStateChange method
- String newState
Records a motion state change.
Implementation
void recordStateChange(String newState) {
final now = DateTime.now();
if (_stateStartTime != null) {
final duration = now.difference(_stateStartTime!);
_timeByState.update(
_currentState,
(existing) => existing + duration,
ifAbsent: () => duration,
);
}
_currentState = newState;
_stateStartTime = now;
}