statisticsQuery static method

Future<Statistics> statisticsQuery(
  1. QuantityType type,
  2. String unit,
  3. Predicate predicate
)

Returns Statistics for the provided type and the, the preferred unit and the time interval predicate predicate.

Warning: The unit should be valid. See preferredUnits.

Implementation

static Future<Statistics> statisticsQuery(
    QuantityType type, String unit, Predicate predicate) async {
  final arguments = <String, dynamic>{
    'identifier': type.identifier,
    'unit': unit,
  };
  arguments.addAll(predicate.map);
  final result =
      await _methodChannel.invokeMethod('statisticsQuery', arguments);
  final Map<String, dynamic> map = jsonDecode(result);
  final statistics = Statistics.fromJson(map);
  return statistics;
}