Open AdamBrejcak opened 5 months ago
Hi, I think I have the similar problem, but with Apple Health and other functions.
I'm using the getHealthDataFromTypes
function to get the values for the current data for ACTIVE_ENERGY_BURNED
, BASAL_ENERGY_BURNED
and DIETARY_ENERGY_CONSUMED
. Besides that I'm also using the getHealthIntervalDataFromTypes
function for the same data types to get the values for each day of the last 7 days.
While getHealthIntervalDataFromTypes
returns the same data as shown in the Apple Health app for the current day, getHealthDataFromTypes
return different values.
To reproduce this, the following app can be run on an iOS device https://github.com/ricoberger/energydiff. If you have the mentioned data in Apple Health, there should be different values for Today and in the History where also the current day is shown (see screenshot). When I run the app on the emulator and insert the Health data manually I can not reproduce this problem.
getHealthDataFromTypes
and getHealthIntervalDataFromTypes
should return the same data for the same time range.
getHealthDataFromTypes
and getHealthIntervalDataFromTypes
are returning different values for the same time range. The values from getHealthDataFromTypes
are the ones which are looking wrong.
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.6.1 23G93 darwin-arm64, locale de-DE)
• Flutter version 3.24.0 on channel stable at /Users/ricoberger/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 80c2e84975 (2 weeks ago), 2024-07-30 23:06:49 +0700
• Engine revision b8800d88be
• Dart version 3.5.0
• DevTools version 2.37.2
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/ricoberger/Library/Android/sdk
• Platform android-34, build-tools 33.0.1
• ANDROID_HOME = /Users/ricoberger/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
[✓] VS Code (version 1.92.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.94.0
[✓] Connected device (4 available)
• Ricos iPhone 15 Pro Max (mobile) • 00008130-000538CE3EF0001C • ios • iOS 17.5.1 21F90
• macOS (desktop) • macos • darwin-arm64 • macOS 14.6.1 23G93 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.6.1 23G93 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.120
[✓] Network resources
• All expected network resources are available.
• No issues found!
[Health 10.2.0] Fetched data are not accurate
Device / Emulator and OS
Describe the bug
I used my personal device for testing. let's say that i went for a walk in the morning at 8am and i did 5000 steps, and this is the only time i did some exercise for today, currently it's 10pm, the issue is when I call Health().getTotalStepsInInterval or even Health().getHealthIntervalDataFromTypes (with STEPS type and READ permission), with time window from 12pm until now (10pm), this will return some steps/value, this is not correct from my perspective as it should return 0 since in given time window i did NOT do any walking/steps
To Reproduce
Implement Health package as per documentation, then use any app which will track your steps (e.g. Samsung Health or Google Fit) make sure this app is allowed in google health connect, add walikng activity (or on physical device walk), in the morning for current day, then request steps from Health package by Health().getTotalStepsInInterval or even by Health().getHealthIntervalDataFrom but only for the afternoon today, see example below
Main idea here is that Health package should return 0 steps if there is no exercise done in given time window
Expected behavior
I would expect in this use case that getTotalStepsInInterval and also getHealthDataFromTypes to return 0 steps/value, since only exercise i did, was done before the time window that was passed in request
Actual behavior
getTotalStepsInInterval will return some steps/value, same with getHealthDataFromTypes (seems it's somehow calculated as average value for given day without considering when the exercise was done)
Flutter doctor -v