BarcodeTrackingSession.fromJSON constructor

BarcodeTrackingSession.fromJSON(
  1. Map<String, dynamic> json
)

Implementation

factory BarcodeTrackingSession.fromJSON(Map<String, dynamic> json) {
  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 BarcodeTrackingSession._(
      addedTrackedCodes, removedTrackedCodes, updatedTrackedCodes, trackedCodes, frameSequenceId);
}