Getting started with the Kotlin Multiplatform Barcode Scanner SDK's Compose UI
Integrating the Compose UI Components
The KMP SDK provides a Compose-based BarcodeScannerCustomUI component that encapsulates the barcode scanning feature in one reusable composable. This component handles camera access, barcode detection, and visual overlays out of the box.
Integration
For an example of a complete integration of the Kotlin Multiplatform Barcode Scanner, please refer to our scanbot-barcode-scanner-sdk-example-kmp repository on GitHub.
Adding the feature as a dependency
To use BarcodeScannerCustomUI, add the Scanbot Compose UI dependency to your KMP project:
commonMain.dependencies {
implementation("io.scanbot:kmp-compose-ui-barcode-sdk:$scanbotSdkVersion")
}
Initializing the SDK
Before using the Scanbot SDK, it must be initialized in your application. For more details on how to initialize the SDK, please refer to the initialization guide.
Using BarcodeScannerCustomUI
To start using the barcode scanner, add the BarcodeScannerCustomUI composable to your screen:
loading...
Main configuration
The Scanbot SDK provides the ability to configure the barcode scanner through BarcodeScannerCustomUI configurations and BarcodeScannerConfiguration. There are two ways of doing this: simplified and advanced.
Simple configuration
Here is an example of a simple configuration modification:
loading...
It provides a straightforward way to configure barcodeFormatConfigurations, extractedDocumentFormats, and onlyAcceptDocuments.
Advanced configuration
For more detailed configuration, you can use the advanced way:
loading...
For the full list of parameters, please refer to the BarcodeScannerConfiguration.
Common configuration
Some use cases require special handling. For example, it is possible to configure the barcode scanner to scan only barcodes of pre-defined lengths. This might reduce the number of false scans. Such parameters work only for enumerated types of barcodes and usually you don't need to modify their default values.
You can specify these parameters via the BarcodeFormatCommonConfiguration entity as a part of BarcodeScannerConfiguration:
loading...
For the full list of parameters, please refer to the BarcodeScannerConfiguration.
Camera configuration
loading...
For the full list of parameters, please refer to the BarcodeScannerCustomUI.
Finder view configuration
Customize the finder overlay appearance and behavior:
loading...
For the full list of parameters, please refer to the FinderViewConfiguration.