queryAverageHeartRate method
Implementation
Future<int> queryAverageHeartRate(int newStartTime, int newEndTime, List list) async {
var start = newStartTime * 1000;
var end = newEndTime * 1000;
DateTime startTime = DateTime.fromMillisecondsSinceEpoch(start);
DateTime endTime = DateTime.fromMillisecondsSinceEpoch(end);
var initTime = getInitTime(startTime);
var startIndex = getIndex(initTime, startTime);
var endIndex = getIndex(initTime, endTime);
int? sum = 0;
for (int i = startIndex; i <= endIndex; i++) {
sum = (sum! + list[i]) as int?;
}
var mean = sum! ~/ (endIndex - startIndex + 1);
return mean;
}