cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
550 stars 675 forks source link

[Health 8.1.0] getTotalStepsInInterval causes Android to crash #851

Open yangyu92 opened 11 months ago

yangyu92 commented 11 months ago

Device / Emulator and OS

Device: android 12 OS: android 12

Describe the bug

getTotalStepsInInterval When you get the number of steps in a year, error:assert(map.size <= 1) { "getTotalStepsInInterval should return only one interval. Found: ${map.size}" } app crash

To Reproduce

Maybe the google fit data is repeating over a certain period of time

Expected behavior

Returns the correct total number of steps

Actual behavior

Application crash

Screenshots

img_v3_025u_5cdecc0a-dd63-4c09-964c-9a1ada373dhu image

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.16.3, on macOS 13.0.1 22A400 darwin-arm64, locale zh-Hans-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Android Studio (version 2022.2) [✓] VS Code (version 1.84.2) [✓] Connected device (3 available) [✓] Network resources • No issues found! Also confirmed reproducible on Flutter 3.16.3,

Additional information

dastbayoo commented 7 months ago

I can confirm this issue. The buckets/interval returned are segments. It seems that if the specified interval does not have contiguous data, Google splits it into segments with contiguous data. Example: Specified range was 60 days. Multiple intervals returned:

yuyangpl commented 7 months ago

我可以确认这个问题。返回的桶/间隔是段。看起来,如果指定的间隔没有连续的数据,Google 会将其分割成具有连续数据的段。 示例: 指定范围为 60 天。 返回多个间隔:

  • 1、6天的步骤
  • 然后是一周后 2 天的数据
  • 然后是另一个间隙,依此类推。

How to fix this

dastbayoo commented 7 months ago

It looks simple in the screenshot above: just remove the assert statement. However, in version 10 the issue still exists and in the meantime the code has changed to only work with one interval.

yangyu92 commented 7 months ago

ok,thanks

发自我的 iPhone

在 2024年4月19日,14:56,dastbayoo @.***> 写道:

It looks simple in the screenshot above: just remove the assert statement. However, in version 10 the issue still exists and in the meantime the code has changed to only work with one interval.