CalibrationInfo constructor

CalibrationInfo(
  1. Map event
)

Implementation

CalibrationInfo(Map<dynamic, dynamic> event) {
  final typeValue = event["calibrationType"] ?? "unknown";
  if (typeValue == "onCalibrationProgress") {
    // When the calibration is in progress, set the type to progress and update the progress value.
    type = CalibrationType.progress;
    progress = event["calibrationProgress"] ?? -1001;
    next = null;
    data = null;
  } else if (typeValue == "onCalibrationNextXY") {
    // When the next calibration point is available, set the type to nextPoint and store the point's coordinates.
    type = CalibrationType.nextPoint;
    progress = null;
    final double x = event["calibrationNextX"] ?? -1001;
    final double y = event["calibrationNextY"] ?? -1001;
    next = Point(x, y);
    data = null;
  } else if (typeValue == "onCalibrationFinished") {
    // When the calibration is finished, set the type to finished and store the calibration data.
    type = CalibrationType.finished;
    progress = null;
    next = null;
    data = List<double>.from(event["calibrationData"] as List);
  } else if (typeValue == "onCalibrationCanceled") {
    // When the calibration is canceled, set the type to canceled and store the calibration data.
    type = CalibrationType.canceled;
    progress = null;
    next = null;
    data = List<double>.from(event["calibrationData"] as List);
  } else {
    // If the event type is unknown, set type to unknown and all other fields to null.
    type = CalibrationType.unknown;
    progress = null;
    next = null;
    data = null;
  }
}