Quantity.fromJson constructor

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

Implementation

factory Quantity.fromJson(Map<String, dynamic> json) => Quantity(
      uuid: json['uuid'] as String,
      start: DateTime.fromMillisecondsSinceEpoch(
        ((json['startTimestamp'] as double) * 1000).toInt(),
      ),
      end: DateTime.fromMillisecondsSinceEpoch(
        ((json['endTimestamp'] as double) * 1000).toInt(),
      ),
      sourceRevision:
          SourceRevision.fromJson(Map.from(json['sourceRevision'])),
      device: json['device'] != null
          ? Device.fromJson(Map.from(json['device']))
          : null,
      metadata: json['metadata'] != null ? Map.from(json['metadata']) : null,
      type: HKQuantityTypeIdentifier.values.firstWhere(
        (e) => e.identifier == json['quantityType'],
      ),
      count: json['count'] as int,
      values: Map.from(json['values']),
    );