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

[flutter health: 3.3.0] Fetching data from a short interval

Open yonycherkos opened this issue 3 years ago • 1 comments

Unable to get height and weight from apple health

Device and OS

Please complete the following information for each phone and/or emulator you're experiencing this bug on:

  • Device: [e.g. iPhone 7]
  • OS: [e.g. iOS 14.7.1]

Describe the bug

I want to get the weight and height of the user from apple health without specifying without specifying time interval or short time interval. I was not able to fetch these data if the date interval is a week or less. but it works if I change it to 2 months or so. and it also works I update my height and weight in the app health and try to fetch even for the 1-day intervals.

To Reproduce

Try to fetch height or weight date using these code sample.

var now = DateTime.now();
var startDate = DateTime(now.year, now.month, now.day - 1);
var endDate = now;

var healthData = await health.getHealthDataFromTypes(
    startDate,
    endDate,
    types,
  );

Expected behavior

To fetch height or weight data that is available on the user apple health without specifying a time interval or with a short time interval(1 day).=

Flutter doctor

Please run flutter doctor and add the output here. yonatan@yonatans-MacBook-Pro ~ % flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.2.3, on macOS 11.6.1 20G224 darwin-x64, locale en-ET) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 2020.3) [✓] VS Code (version 1.62.2) [✓] Connected device (1 available)

• No issues found!

yonycherkos avatar Nov 15 '21 14:11 yonycherkos

Hey @yonycherkos

This is intended behaviour from the plug-in. Health looks for any data point with the given type in the interval you specified. If the user has not entered a weight during that time, then no datapoint will be returned.

When you look for the last 2 months it finds data, but maybe you didn't input weight & height data during the last day, so it seems like it doesn't work, but there are simply no data points during that time.

If I misunderstood the issue, feel free to write me or clarify the issue.

Regards, Mads

MadsVSChristensen avatar Mar 02 '22 14:03 MadsVSChristensen