carp_health_package 2.4.0 icon indicating copy to clipboard operation
carp_health_package: ^2.4.0 copied to clipboard

CARP health sampling package. Samples health data from Apple Health or Google Fit.

CARP Health Sampling Package #

This library contains a sampling package for sampling health data from Apple Health and/or Google Fit to work with the carp_mobile_sensing framework. This packages supports sampling of the following Measure types:

  • dk.cachet.carp.health

A HealthMeasure can be configured to collect a specific HealthDataType.

A HealthDataType can be:

  • BODY_FAT_PERCENTAGE,
  • HEIGHT,
  • WEIGHT,
  • BODY_MASS_INDEX,
  • WAIST_CIRCUMFERENCE,
  • STEPS,
  • ...

See the HealthDataType documentation for a complete list.

See the wiki for further documentation, particularly on available measure types. See the CARP Mobile Sensing App for an example of how to build a mobile sensing app in Flutter.

For Flutter plugins for other CARP products, see CARP Mobile Sensing in Flutter.

If you're interested in writing you own sampling packages for CARP, see the description on how to extend CARP on the wiki.

Installing #

To use this package, add the following to you pubspc.yaml file. Note that this package only works together with carp_mobile_sensing.

dependencies:
  flutter:
    sdk: flutter
  carp_core: ^latest
  carp_mobile_sensing: ^latest
  carp_health_package: ^latest
  ...

Android Integration #

This package uses AndroidX. See Flutter AndroidX compatibility

Replace the content of the android/gradle.properties file with the following lines:

org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
android.useAndroidX=true

Google Fit can be tricky to set up and it requires a separate app to be installed. Please follow this guide to set up Google Fit. Also - check out the documentation of the health package.

iOS Integration #

Add this permission in the Info.plist file located in ios/Runner:

<key>NSHealthShareUsageDescription</key>
<string>We will sync your data with the Apple Health app to give you better insights</string>
<key>NSHealthUpdateUsageDescription</key>
<string>We will sync your data with the Apple Health app to give you better insights</string>

Using it #

To use this package, import it into your app together with the carp_mobile_sensing package:

import 'package:carp_core/carp_core.dart';
import 'package:carp_mobile_sensing/carp_mobile_sensing.dart';
import 'package:carp_health_package/health.dart';

Before creating a study and running it, register this package in the SamplingPackageRegistry.

SamplingPackageRegistry().register(HealthSamplingPackage());

When defining a study protocol with this health measure, it would look like this:

  // collect weight every day at 23:00
  protocol.addTriggeredTask(
      RecurrentScheduledTrigger(
          type: RecurrentType.daily, time: TimeOfDay(hour: 23, minute: 00)),
      BackgroundTask()
        ..addMeasure(Measure(type: HealthSamplingPackage.HEALTH)
          ..overrideSamplingConfiguration = HealthSamplingConfiguration(
              healthDataTypes: [HealthDataType.WEIGHT])),
      phone);

See the example.dart file for a full example of how to set up a CAMS study protocol for this sampling package.

6
likes
140
pub points
58%
popularity

Publisher

verified publisher iconcachet.dk

CARP health sampling package. Samples health data from Apple Health or Google Fit.

Homepage

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

carp_core, carp_mobile_sensing, carp_serializable, flutter, health, json_annotation, permission_handler, uuid

More

Packages that depend on carp_health_package