Category.fromJson constructor
Category.fromJson(
- Map<String, dynamic> json
)
Implementation
factory Category.fromJson(Map<String, dynamic> json) {
return Category(
uuid: json['uuid'] as String,
start: DateTime.fromMillisecondsSinceEpoch(
((json['startTimestamp'] as double) * 1000).toInt(),
),
end: DateTime.fromMillisecondsSinceEpoch(
((json['endTimestamp'] as double) * 1000).toInt(),
),
type: HKCategoryTypeIdentifier.values.firstWhere(
(e) => e.identifier == json['categoryType'],
),
sourceRevision: SourceRevision.fromJson(Map.from(json['sourceRevision'])),
device: json['device'] != null
? Device.fromJson(Map.from(json['device']))
: null,
value: json['value'] as int,
metadata: json['metadata'] != null ? Map.from(json['metadata']) : null,
);
}