Correlation.fromJson constructor

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

Implementation

factory Correlation.fromJson(Map<String, dynamic> json) {
  return Correlation(
    uuid: json['uuid'] as String,
    start: DateTime.fromMillisecondsSinceEpoch(
      ((json['startTimestamp'] as double) * 1000).toInt(),
    ),
    end: DateTime.fromMillisecondsSinceEpoch(
      ((json['endTimestamp'] as double) * 1000).toInt(),
    ),
    type: HKCorrelationTypeIdentifier.values.firstWhere(
      (e) => e.identifier == json['correlationType'],
    ),
    sourceRevision: SourceRevision.fromJson(Map.from(json['sourceRevision'])),
    device: json['device'] != null
        ? Device.fromJson(Map.from(json['device']))
        : null,
    objects: (json['objects'] as List)
        .map((e) => Quantity.fromJson(Map.from(e)))
        .toList(),
    metadata: json['metadata'] != null ? Map.from(json['metadata']) : null,
  );
}