cadence property

double get cadence

Implementation

double get cadence {
  final now = DateTime.now();
  final recent = _todayStepTimestamps
      .where((ts) => now.difference(ts).inSeconds <= 60)
      .toList();
  return recent.isEmpty ? 0 : (recent.length.toDouble());
  // if (_todayStepTimestamps.length < 2) return 0;
  // final duration = _todayStepTimestamps.last
  //     .difference(_todayStepTimestamps.first)
  //     .inMinutes;
  // return duration == 0 ? 0 : (_todayStepTimestamps.length / duration);
}