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

[Health 8.1.0] getTotalStepsInInterval causes Android to crash

Open yangyu92 opened this issue 1 year ago • 4 comments

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

yangyu92 avatar Dec 08 '23 03:12 yangyu92

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:

  • one with the steps of 6 days
  • then one with data of a week later for 2 days
  • then another gap and so on.

dastbayoo avatar Apr 18 '24 08:04 dastbayoo

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

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

How to fix this

yuyangpl avatar Apr 19 '24 03:04 yuyangpl

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.

dastbayoo avatar Apr 19 '24 06:04 dastbayoo

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.

yangyu92 avatar Apr 19 '24 09:04 yangyu92