correlationQuery static method
Returns Correlation samples for the provided identifier
, the
time interval predicate predicate
and optional typePredicates
for
Category and/or Quantity values.
Warning: In order to use the correlations, you must be sure, that you have provided reading permissions for relevant QuantityType.
For instance, if you want to get the data for CorrelationType.bloodPressure,
you need to ask user to give read permissions for QuantityType.bloodPressureDiastolic and
QuantityType.bloodPressureSystolic. Otherwise HealthKit
will throw fatal error with
message: "Authorization to read the following types is disallowed:
HKCorrelationTypeIdentifierBloodPressure".
Implementation
static Future<List<Correlation>> correlationQuery(
String identifier, Predicate predicate,
{Map<String, Predicate>? typePredicates}) async {
final arguments = {
'identifier': identifier,
'typePredicates': typePredicates,
};
arguments.addAll(predicate.map);
final result =
await _methodChannel.invokeMethod('correlationQuery', arguments);
final List<dynamic> list = jsonDecode(result);
final correlations = <Correlation>[];
for (final Map<String, dynamic> map in list) {
final correlation = Correlation.fromJson(map);
correlations.add(correlation);
}
return correlations;
}