getData method
Future<List<HealthConnectData> >
getData(
- List<
HealthConnectHealthMetric> metrics, - DateTimeRange<
DateTime> timeRange
override
Retrieves health data for specified metrics within the given time range. Returns a list of typed health data objects (heart rate, skin temperature, etc.).
Implementation
@override
Future<List<HealthConnectData>> getData(
List<HealthConnectHealthMetric> 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(
"$healthConnectPrefix/$getDataSuffix",
{"start": start, "end": end, "types": types},
);
if (response == null) {
throw Exception("[HealthConnect] getData returned null");
}
List<HealthConnectData> result = _convertToHealthConnectData(response);
return result;
}