getHealthDataFromTypes method

Future<List<HealthDataPoint>> getHealthDataFromTypes(
  1. DateTime startTime,
  2. DateTime endTime,
  3. List<HealthDataType> types
)

Fetch a list of health data points based on types.

Implementation

Future<List<HealthDataPoint>> getHealthDataFromTypes(
  DateTime startTime,
  DateTime endTime,
  List<HealthDataType> types,
) async {
  List<HealthDataPoint> dataPoints = [];

  for (var type in types) {
    final result = await _prepareQuery(startTime, endTime, type);
    dataPoints.addAll(result);
  }

  const int threshold = 100;
  if (dataPoints.length > threshold) {
    return compute(removeDuplicates, dataPoints);
  }

  return removeDuplicates(dataPoints);
}