Skip to content

[health: 13.1.0] Calling getHealthDataFromTypes with multiple types, when one type does not have permission, throws and does not return any data #21

@biklas7

Description

@biklas7

Plugin Name

health

Plugin Version

13.1.0

Device

iPhone 12 Pro

Operating System

18.5

Describe the bug

getHealthDataFromTypes supports a list of HealthDataType to read from, but if at least one of the given types doesn't have user permission, the whole function throws and does not return any results, even though it got results from the other given types that the user gave permission for.

Steps to Reproduce

  1. Set up Apple Health so the app has read permission for HealthDataType.BLOOD_GLUCOSE but not for HealthDataType.INSULIN_DELIVERY.
  2. Make sure you have data on Apple Health for those types, if not, add some mock data.
  3. Call getHealthDataFromTypes with types: [HealthDataType.BLOOD_GLUCOSE, HealthDataType.INSULIN_DELIVERY]
  4. Notice that it will be able to get that for HealthDataType.BLOOD_GLUCOSE
  5. But then will throw when trying to read HealthDataType.INSULIN_DELIVERY
  6. And all the data is lost

Expected Behavior

It should catch the throw and return the data from HealthDataType.BLOOD_GLUCOSE or, in more general terms, that function should not throw if it was able to get data for at least one type, because otherwise it's just throwing data away and we could argue that if that's the intended behavior, then it should not accept a list required List<HealthDataType> types.

Actual Behavior

It throws and tosses all the data, even though it was able to read from the types that it had permission for.

Flutter Logs

Screenshots

No response

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.32.4, on macOS 15.5 24F74 darwin-arm64, locale en-PT) [439ms]
    • Flutter version 3.32.4 on channel stable at /opt/homebrew/Caskroom/flutter/3.13.7/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6fba2447e9 (10 days ago), 2025-06-12 19:03:56 -0700
    • Engine revision 8cd19e509d
    • Dart version 3.8.1
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,938ms]
    • Android SDK at /Users/antonio/Library/Android/sdk
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [1,715ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [11ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [10ms]
    • 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 21.0.6+-13368085-b895.109)

[✓] VS Code (version 1.96.4) [9ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (3 available) [5.9s]
    • António’s iPhone (mobile) • 00008101-00163D3C0A78001E • ios            • iOS 18.5 22F76
    • macOS (desktop)           • macos                     • darwin-arm64   • macOS 15.5 24F74 darwin-arm64
    • Chrome (web)              • chrome                    • web-javascript • Google Chrome 137.0.7151.120

[✓] Network resources [537ms]
    • All expected network resources are available.

• No issues found!

Additional Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions