BarcodeScanScreen

fun BarcodeScanScreen(modifier: Modifier = Modifier, supportedCodeTypes: Set<Barcode.Type> = EnumSet.allOf(Barcode.Type::class.java), previewScaleType: PreviewScaleType = PreviewScaleType.FIT, overlayColor: Color = Color.Blue, onBarcodesDetected: (codes: List<SpatialBarcode>) -> Unit = { _ -> }, onBarcodeDetectionFailed: (Exception) -> Unit = { _ -> }, onDetectorInitializationFailed: (Exception) -> Unit = { _ -> }, onCameraReady: () -> Unit = {}, onCameraFailure: (Exception) -> Unit = {})

Displays a camera preview that detects barcodes and draws their bounds and values.

The caller must obtain the Android camera permission before adding this composable to the composition. Camera resources are released when it leaves the composition.

Parameters

modifier

Modifier applied to the camera screen.

supportedCodeTypes

Barcode formats to detect. All supported formats are enabled by default.

previewScaleType

Whether the preview fits within or fills its available bounds.

overlayColor

Color used for barcode bounds and values.

onBarcodesDetected

Called with the barcodes detected in each analyzed frame. An empty list is reported when no barcode is detected.

onBarcodeDetectionFailed

Called when barcode detection fails for a camera frame.

onDetectorInitializationFailed

Called when the barcode detector cannot be initialized.

onCameraReady

Called when the camera is initialized and ready.

onCameraFailure

Called when the camera cannot be initialized.