BarcodeBatchSession.fromJSON constructor
BarcodeBatchSession.fromJSON(
- Map<String, dynamic> eventJson
)
Implementation
factory BarcodeBatchSession.fromJSON(Map<String, dynamic> eventJson) {
var json = jsonDecode(eventJson['session']);
var frameSequenceId = json['frameSequenceId'] as int;
var addedTrackedCodes = (json['addedTrackedBarcodes'] as List)
.map((trackedCodeJSON) => TrackedBarcode.fromJSON(trackedCodeJSON, sessionFrameSequenceId: frameSequenceId))
.toList();
var updatedTrackedCodes = (json['updatedTrackedBarcodes'] as List)
.map((trackedCodeJSON) => TrackedBarcode.fromJSON(trackedCodeJSON, sessionFrameSequenceId: frameSequenceId))
.toList();
var removedTrackedCodes = (json['removedTrackedBarcodes'] as List)
// ignore: unnecessary_lambdas
.map((id) => int.parse(id))
.toList();
var trackedCodes = (json['trackedBarcodes'] as Map).cast<String, Map<String, dynamic>>().map<int, TrackedBarcode>(
(key, value) =>
MapEntry(int.parse(key), TrackedBarcode.fromJSON(value, sessionFrameSequenceId: frameSequenceId)));
return BarcodeBatchSession._(
addedTrackedCodes,
removedTrackedCodes,
updatedTrackedCodes,
trackedCodes,
frameSequenceId,
eventJson['frameId'],
);
}