StatusInfo constructor

StatusInfo(
  1. Map event
)

Implementation

StatusInfo(Map<dynamic, dynamic> event) {
  final String typeValue = event["statusEventType"] ?? "";
  if (typeValue == "start") {
    // If the event type is "start", set the status type to start and error type to null.
    type = StatusType.start;
    errorType = null;
  } else if (typeValue == "stop") {
    // If the event type is "stop", set the status type to stop and determine the error type if available.
    type = StatusType.stop;

    final String errorTypeValue = event["statusFailedReason"] ?? "error";
    if (errorTypeValue == "ERROR_NONE") {
      // No error occurred.
      errorType = StatusErrorType.none;
    } else if (errorTypeValue == "ERROR_CAMERA_START") {
      // An error occurred while starting the camera.
      errorType = StatusErrorType.cameraStart;
    } else if (errorTypeValue == "ERROR_CAMERA_INTERRUPT") {
      // An error occurred due to camera interruption.
      errorType = StatusErrorType.cameraInterrupt;
    } else {
      // If the error type is unknown, set it to unknown.
      errorType = StatusErrorType.unknown;
    }
  } else {
    // If the event type is not recognized, set type to unknown and errorType to unknown.
    // This means we cannot determine if it is a start or stop event.
    type = StatusType.unknown;
    errorType = StatusErrorType.unknown;
  }
}