flutter-plugins icon indicating copy to clipboard operation
flutter-plugins copied to clipboard

[Health: 9.0.1] Total number in interval

Open B1GMAX opened this issue 1 year ago • 2 comments

It would be great to have a getTotalInInterval method for each data type. Currently, only steps have a method for obtaining a total number within a specified interval - getTotalStepsInInterval. Other data types can only be read using getHealthDataFromTypes, which returns a list of small periods of data collected from different sources. When I attempt to concatenate these intervals, I obtain a different number than what the native Google Fit or Apple Health apps. This discrepancy is primarily due to overlapping intervals from different tracking sources.

B1GMAX avatar Feb 13 '24 15:02 B1GMAX

I noticed the same problem. There are native Android and iOS methods to get the total number for a period, so we can use them in a Flutter app in the same way as getTotalStepsInInterval. I have created a new pull request with the new methods getTotalCaloriesInInterval and getTotalDistanceInInterval added. You can either wait for it to be merged or use it right away as a git dependency in your pubspec:

dependencies:
  flutter:
    sdk: flutter
    
  health:
    git:
      url: https://github.com/YatsenkoDev/flutter-plugins.git
      path: packages/health

YatsenkoDev avatar Feb 14 '24 16:02 YatsenkoDev

it gives null

Umang-Shriwas avatar Feb 26 '24 06:02 Umang-Shriwas