kvs-coder / health_kit_reporter

A Flutter wrapper for the HealthKitReporter library
https://pub.dev/packages/health_kit_reporter
MIT License
38 stars 38 forks source link

Calling `statisticsQuery` for a `QuantityType` that does not have any data in Health Kit should not throw. #49

Closed quentinleguennec closed 2 years ago

quentinleguennec commented 2 years ago

Is your feature request related to a problem? Please describe. Calling statisticsQuery for a QuantityType that does not have any data in Health Kit throws an error (see below) rather than returning a Statistics object with the values set to null.

Describe the solution you'd like To maintain consistency with the behaviour observed when data does exists for the queried type but there is no data in the query time frame (for example if there is only one data point for the queried type on 06/06/22, but the query Predicate is for 07/06/22 to 08/06/22), it would be good if the function returned a Statistics object with the values set to null instead of throwing an error.

Describe alternatives you've considered Doing a Try/Catch works, but it's counter-intuitive and more expensive.

Additional context See #48

kvs-coder commented 2 years ago

Hi @quentinleguennec

The library is based on the original HealthKit Api, and by calling a statistics query if no data available, the original Api will throw an error