HealthDataPoint constructor

HealthDataPoint({
  1. required HealthValue value,
  2. required HealthDataType type,
  3. required HealthDataUnit unit,
  4. required DateTime dateFrom,
  5. required DateTime dateTo,
  6. required HealthPlatformType sourcePlatform,
  7. required String sourceDeviceId,
  8. required String sourceId,
  9. required String sourceName,
  10. bool isManualEntry = false,
  11. WorkoutSummary? workoutSummary,
})

Implementation

HealthDataPoint({
  required this.value,
  required this.type,
  required this.unit,
  required this.dateFrom,
  required this.dateTo,
  required this.sourcePlatform,
  required this.sourceDeviceId,
  required this.sourceId,
  required this.sourceName,
  this.isManualEntry = false,
  this.workoutSummary,
}) {
  // set the value to minutes rather than the category
  // returned by the native API
  if (type == HealthDataType.MINDFULNESS ||
      type == HealthDataType.HEADACHE_UNSPECIFIED ||
      type == HealthDataType.HEADACHE_NOT_PRESENT ||
      type == HealthDataType.HEADACHE_MILD ||
      type == HealthDataType.HEADACHE_MODERATE ||
      type == HealthDataType.HEADACHE_SEVERE ||
      type == HealthDataType.SLEEP_IN_BED ||
      type == HealthDataType.SLEEP_ASLEEP ||
      type == HealthDataType.SLEEP_AWAKE ||
      type == HealthDataType.SLEEP_DEEP ||
      type == HealthDataType.SLEEP_LIGHT ||
      type == HealthDataType.SLEEP_REM ||
      type == HealthDataType.SLEEP_OUT_OF_BED) {
    value = _convertMinutes();
  }
}