DocumentScannerCameraConfiguration.fromJson constructor

DocumentScannerCameraConfiguration.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory DocumentScannerCameraConfiguration.fromJson(
        Map<String, dynamic> json) =>
    DocumentScannerCameraConfiguration(
      cameraModule: json.containsKey("cameraModule")
          ? CameraModule.values.byName(json["cameraModule"] as String)
          : CameraModule.BACK,
      defaultZoomFactor: json.containsKey("defaultZoomFactor")
          ? (json["defaultZoomFactor"] as num).toDouble()
          : 1.0,
      flashEnabled: json.containsKey("flashEnabled")
          ? (json["flashEnabled"] as bool)
          : false,
      minFocusDistanceLock: json.containsKey("minFocusDistanceLock")
          ? (json["minFocusDistanceLock"] as bool)
          : false,
      touchToFocusEnabled: json.containsKey("touchToFocusEnabled")
          ? (json["touchToFocusEnabled"] as bool)
          : false,
      pinchToZoomEnabled: json.containsKey("pinchToZoomEnabled")
          ? (json["pinchToZoomEnabled"] as bool)
          : true,
      cameraPreviewMode: json.containsKey("cameraPreviewMode")
          ? CameraPreviewMode.values
              .byName(json["cameraPreviewMode"] as String)
          : CameraPreviewMode.FILL_IN,
      captureQualityPrioritization:
          json.containsKey("captureQualityPrioritization")
              ? CapturePhotoQualityPrioritization.values
                  .byName(json["captureQualityPrioritization"] as String)
              : CapturePhotoQualityPrioritization.BALANCED,
      acceptedAngleScore: json.containsKey("acceptedAngleScore")
          ? (json["acceptedAngleScore"] as num).toDouble()
          : 0.75,
      acceptedSizeScore: json.containsKey("acceptedSizeScore")
          ? (json["acceptedSizeScore"] as num).toDouble()
          : 0.75,
      autoSnappingSensitivity: json.containsKey("autoSnappingSensitivity")
          ? (json["autoSnappingSensitivity"] as num).toDouble()
          : 0.66,
      autoSnappingDelay: json.containsKey("autoSnappingDelay")
          ? (json["autoSnappingDelay"] as int)
          : 200,
      acceptedBrightnessThreshold:
          json.containsKey("acceptedBrightnessThreshold")
              ? (json["acceptedBrightnessThreshold"] as int)
              : 50,
      autoSnappingEnabled: json.containsKey("autoSnappingEnabled")
          ? (json["autoSnappingEnabled"] as bool)
          : true,
      requiredAspectRatios: json.containsKey("requiredAspectRatios")
          ? (json["requiredAspectRatios"] as List<dynamic>)
              .map((it) => AspectRatio.fromJson(it as Map<String, dynamic>))
              .toList()
          : [],
      ignoreBadAspectRatio: json.containsKey("ignoreBadAspectRatio")
          ? (json["ignoreBadAspectRatio"] as bool)
          : true,
      captureWithHardwareButtonsEnabled:
          json.containsKey("captureWithHardwareButtonsEnabled")
              ? (json["captureWithHardwareButtonsEnabled"] as bool)
              : true,
    );