HealthDataPoint.fromJson constructor
HealthDataPoint.fromJson(
- dynamic json
Converts a json object to the HealthDataPoint
Implementation
factory HealthDataPoint.fromJson(json) {
HealthValue healthValue;
if (json['data_type'] == 'audiogram') {
healthValue = AudiogramHealthValue.fromJson(json['value']);
} else {
healthValue = NumericHealthValue.fromJson(json['value']);
}
return HealthDataPoint(
healthValue,
HealthDataType.values.firstWhere(
(element) => element.typeToString() == json['data_type']),
HealthDataUnit.values
.firstWhere((element) => element.typeToString() == json['unit']),
DateTime.parse(json['date_from']),
DateTime.parse(json['date_to']),
PlatformTypeJsonValue.keys.toList()[PlatformTypeJsonValue.values
.toList()
.indexOf(json['platform_type'])],
json['device_id'],
json['source_id'],
json['source_name']);
}