recentSessions static method

Future<List<SessionRecord>> recentSessions({
  1. int days = 7,
})

Sessions in the last N days, newest first.

Implementation

static Future<List<SessionRecord>> recentSessions({int days = 7}) async {
  final records = await getHistory();
  final cutoff = DateTime.now().subtract(Duration(days: days));
  return records.where((r) => r.startedAt.isAfter(cutoff)).toList();
}