Skip to content

HealthData

One health data point from Apple Health or Google Health Connect.

This is the data of every measurement collected by the HealthProbe. It is created from the health plugin's HealthDataPoint using HealthData.fromHealthDataPoint. All health data has the same JSON type, dk.cachet.carp.health (HealthSamplingPackage.HEALTH); the kind of data is given by healthDataType.

Key points:

Inheritance
Annotations

Constructors

HealthData.fromHealthDataPoint

HealthData.fromHealthDataPoint(
  1. HealthDataPoint healthDataPoint
)

Creates a HealthData from a health plugin HealthDataPoint.

HealthData.fromJson

HealthData.fromJson(
  1. Map<String, dynamic> json
)

HealthData

HealthData({
  1. required String uuid,
  2. required HealthValue value,
  3. required String unit,
  4. required String healthDataType,
  5. required DateTime dateFrom,
  6. required DateTime dateTo,
  7. required HealthPlatform platform,
  8. String? deviceId,
  9. String? sourceId,
  10. String? sourceName,
})

Creates a HealthData object. dateFrom and dateTo are converted to UTC.

Properties

dateFrom

DateTime dateFrom
getter/setter pair

Start time of this health data, in UTC.

dateTo

DateTime dateTo
getter/setter pair

End time of this health data, in UTC.

deviceId

String? deviceId
getter/setter pair

The id of the device the data point was fetched from.

fromJsonFunction

Function get fromJsonFunction
override

The function which can convert a JSON string to an object of this type.

healthDataType

String healthDataType
getter/setter pair

The name of the HealthDataType of this data point.

Note that the uppercase version is used, e.g. STEPS.

jsonType

String get jsonType
override

The JSON type of all health data, dk.cachet.carp.health (HealthSamplingPackage.HEALTH), whatever the healthDataType.

platform

HealthPlatform platform
getter/setter pair

The platform this health data point came from.

recordId

String? get recordId
override

Stable identifier of the source record, if available.

sourceId

String? sourceId
getter/setter pair

The id of the source from which the data point was fetched.

sourceName

String? sourceName
getter/setter pair

The name of the source from which the data point was fetched.

unit

String unit
getter/setter pair

Unit of health data.

Note that the uppercase version is used, e.g. COUNT in the case of step counts.

uuid

String uuid
getter/setter pair

A unique UUID of this data point.

value

HealthValue value
getter/setter pair

The value of the health data, for example a NumericHealthValue.

See HealthValue.

Methods

toJson

Map<String, dynamic> toJson()
override

Return a JSON encoding of this object.

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.