carp_health_package 0.8.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

CARP Health Sampling Package #

pub 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:

  • 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 and sampling schemas.

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_mobile_sensing: ^0.6.0
  carp_health_package: ^0.6.0
  ...

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_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());

0.7.0 #

  • upgrade to carp_mobile_sensing v. 0.7.x

0.6.5 #

  • upgrade to carp_mobile_sensing v. 0.6.5

0.6.2 #

  • Small update on the documentation and printing.

0.6.1 #

  • Small updates to documentation and adding an example.

0.6.0 #

  • Initial release depending on version 0.6.x of carp_mobile_sensing

example/lib/main.dart

import 'package:carp_health_package/health_package.dart';
import 'package:carp_mobile_sensing/carp_mobile_sensing.dart';

/// This is a very simple example of how this sampling package is used with CARP Mobile Sensing (CAMS).
/// NOTE, however, that the code below will not run.
/// See the documentation on how to use CAMS: https://github.com/cph-cachet/carp.sensing-flutter/wiki
void main() async {
  SamplingPackageRegistry.register(HealthSamplingPackage());

  Study study = Study("1234", "bardram", name: "bardram study");

  // creating a task collecting step counts and blood pressure data for the last two days
  study.addTriggerTask(
    ImmediateTrigger(), // a simple trigger that starts immediately
    Task(name: 'Step and blood pressure')
      ..addMeasure(
        HealthMeasure(
          MeasureType(NameSpace.CARP, HealthSamplingPackage.HEALTH),
          healthDataType: HealthDataType.STEPS,
          name: 'Steps',
        ),
      )
      ..addMeasure(
        HealthMeasure(MeasureType(NameSpace.CARP, HealthSamplingPackage.HEALTH),
            healthDataType: HealthDataType.BLOOD_PRESSURE_DIASTOLIC,
            history: Duration(days: 2),
            name: 'Blood Pressure Diastolic'),
      )
      ..addMeasure(
        HealthMeasure(MeasureType(NameSpace.CARP, HealthSamplingPackage.HEALTH),
            healthDataType: HealthDataType.BLOOD_PRESSURE_SYSTOLIC,
            history: Duration(days: 2),
            name: 'Blood Pressure Systolic'),
      ),
  );

  // Create a Study Controller that can manage this study, initialize it, and start it.
  StudyController controller = StudyController(study);

  // await initialization before starting
  await controller.initialize();
  controller.resume();

  // listening on all data events from the study
  controller.events.forEach(print);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  carp_health_package: ^0.8.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:carp_health_package/health_domain.dart';
import 'package:carp_health_package/health_package.dart';
import 'package:carp_health_package/health_package.g.dart';
import 'package:carp_health_package/health_probe.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jul 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Android

Because:

  • package:carp_health_package/health_package.dart that imports:
  • package:carp_mobile_sensing/domain/domain.dart that imports:
  • package:carp_mobile_sensing/carp_mobile_sensing.dart that imports:
  • package:carp_mobile_sensing/runtime/runtime.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform Linux

Because:

  • package:carp_health_package/health_package.dart that imports:
  • package:permission_handler/permission_handler.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:carp_health_package/health_package.dart that imports:
  • package:permission_handler/permission_handler.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:carp_health_package/health_package.dart that imports:
  • package:permission_handler/permission_handler.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform iOS

Because:

  • package:carp_health_package/health_package.dart that imports:
  • package:carp_mobile_sensing/domain/domain.dart that imports:
  • package:carp_mobile_sensing/carp_mobile_sensing.dart that imports:
  • package:carp_mobile_sensing/sampling_packages/apps/apps.dart that imports:
  • package:device_apps/device_apps.dart that declares support for platforms: Android

Package does not support Flutter platform macOS

Because:

  • package:carp_health_package/health_package.dart that imports:
  • package:permission_handler/permission_handler.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • carp_health_package that is a package requiring null.

Health suggestions

Format lib/health_domain.dart.

Run flutter format to format lib/health_domain.dart.

Format lib/health_package.dart.

Run flutter format to format lib/health_package.dart.

Format lib/health_probe.dart.

Run flutter format to format lib/health_probe.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
carp_mobile_sensing ^0.8.0 0.8.0
flutter 0.0.0
health ^1.0.1 1.0.2+2
json_annotation ^3.0.0 3.0.1
Transitive dependencies
app_usage 0.1.0
archive 2.0.13
args 1.6.0
async 2.4.2
battery 1.0.1
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
device_apps 1.0.10
device_info 0.4.2+4
file 5.2.1
file_utils 0.1.4
flutter_web_plugins 0.0.0
globbing 0.3.1
intl 0.16.1
light 0.1.1
meta 1.1.8 1.2.2
package_info 0.4.1
path 1.7.0
path_provider 1.6.11
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
pedometer 1.2.0
permission_handler 5.0.1+1
permission_handler_platform_interface 2.0.1
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
screen_state 0.1.1
sensors 0.4.2+2
shared_preferences 0.5.8
shared_preferences_linux 0.0.2+1
shared_preferences_macos 0.0.1+10
shared_preferences_platform_interface 1.0.4
shared_preferences_web 0.1.2+7
sky_engine 0.0.99
stats 1.0.0
system_info 0.1.3
typed_data 1.1.6 1.2.0
uuid 2.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
build_runner any
flutter_test
json_serializable ^3.0.0
test any