getRawData method
Future<HealthData>
getRawData(
- List<
HealthKitHealthMetric> metrics, - DateTimeRange<
DateTime> timeRange
override
Retrieves raw health data for specified metrics within the given time range. Returns a HealthData object containing the unprocessed data grouped by metric type.
Implementation
@override
Future<HealthData> getRawData(
List<HealthKitHealthMetric> metrics,
DateTimeRange timeRange,
) async {
final start = timeRange.start.toUtc().toIso8601String();
final end = timeRange.end.toUtc().toIso8601String();
List<String> types = [];
for (final metric in metrics) {
types.add(metric.definition);
}
Map<String, List<dynamic>>? response = await methodChannel.invokeMapMethod(
"$healthKitPrefix/$getDataSuffix",
{"start": start, "end": end, "types": types},
);
if (response == null) {
throw Exception("[HealthKit] getRawData returned null");
}
HealthData result = _convertToHealthData(response);
return result;
}