sampleQuery static method

Future<List<Sample>> sampleQuery(
  1. String identifier,
  2. Predicate predicate
)

Returns Sample samples for the provided identifier and the time interval predicate predicate.

If identifier was recognized as one of QuantityType, the units will be set automatically by original library HealthKitReporter according to SI. See https://cocoapods.org/pods/HealthKitReporter file Extensions+HKQuantityType.swift

Implementation

static Future<List<Sample>> sampleQuery(
    String identifier, Predicate predicate) async {
  final arguments = <String, dynamic>{
    'identifier': identifier,
  };
  arguments.addAll(predicate.map);
  final result = await _methodChannel.invokeMethod('sampleQuery', arguments);
  final list = List.from(result);
  final samples = <Sample>[];
  for (final String element in list) {
    final json = jsonDecode(element);
    final sample = Sample.factory(json);
    if (sample != null) {
      samples.add(sample);
    }
  }
  return samples;
}