Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health 12/1097 Lean Body Mass Type #1108

Merged
merged 11 commits into from
Jan 6, 2025
Merged

Conversation

iarata
Copy link
Contributor

@iarata iarata commented Jan 5, 2025

  • Adds Lean body mass data type to health (both iOS and Android)

Current issues:
The data type can be written, however, when reading back the lean_body_mass it is not able to convert to json (some values result in null).

flutter: Exception in printDataPoint: Converting object to an encodable object failed: Instance of 'HealthDataPoint'

Debug Execpetion:

#0      _JsonStringifier.writeObject (dart:convert/json.dart:793:7)
#1      _JsonStringStringifier.printOn (dart:convert/json.dart:982:17)
#2      _JsonStringStringifier.stringify (dart:convert/json.dart:967:5)
#3      JsonEncoder.convert (dart:convert/json.dart:345:30)
#4      toJsonString (package:carp_serializable/carp_serializable.dart:230:39)
#5      _HealthAppState.fetchData (package:health_example/main.dart:183:20)
<asynchronous suspension>

...

cause = _TypeError (Null check operator used on a null value)

...

unsupportedObject = HealthDataPoint (HealthDataPoint -
    uuid: 44710870-DF07-4F75-A5F7-CB7DECC26AAD,
    value: NumericHealthValue - numericValue: 22.0,
    unit: KILOGRAM,
    dateFrom: 2025-01-05 16:20:26.074,
    dateTo: 2025-01-05 16:40:26.074,
    dataType: LEAN_BODY_MASS,
    platform: HealthPlatformType.appleHealth,
    deviceId: 60569EED-5777-4644-ABFB-C4014B0880BE,
    sourceId: dk.cachet.example,
    sourceName: health_example
    recordingMethod: RecordingMethod.automatic
    workoutSummary: null
    metadata: null)

@SlimShadyIAm Any idea why this is happening, given that there are other instances of HealthDataPoint such as SLEEP_DEEP with the way they're added to the records:

success &= await Health().writeHealthData(
        value: 0.0,
        type: HealthDataType.SLEEP_DEEP,
        startTime: earlier,
        endTime: now);
success &= await Health().writeHealthData(
      value: 22, 
      type: HealthDataType.LEAN_BODY_MASS, 
      startTime: earlier,
      endTime: now);

@iarata
Copy link
Contributor Author

iarata commented Jan 6, 2025

Closes #1078

@iarata iarata merged commit 36ccf84 into iarata/health-12 Jan 6, 2025
1 check passed
@iarata iarata deleted the health-12/1097-lean-mass branch January 6, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants