Barcode-Kit
Overview
Barcode-Kit is a flutter package that allows you to read barcodes using the camera. It uses native textures to display the camera feed and the barcode overlay. It is built on top of the Google ML Kit and iOS Vision for barcode scanning.
It ships as a single widget that handles most of the work for you.
Prerequisites
- Flutter SDK installed on your machine.
- Familiarity with Flutter development.
Installation
Add the mtrust_barcode_kit
to your Flutter project via the pub add
command
flutter pub add mtrust_barcode_kit
or manually add it to your pubspec.yaml
dependencies:
mtrust_barcode_kit: ^2.0.2
Usage
BarcodeKitView(
// The barcode formats to scan
formats: _formats,
cameraFit: BoxFit.cover,
// The camera overlay mask
maskHeight: 200,
maskWidth: 200,
widgetAboveMask: Widget // Place something above the camera cutout,
widgetBelowMask: Widget // Place something below the camera cutout,
// Whether the camera feed is frozen and barcode scanning is paused
paused: true/false,
maskAdditionpauseOpacity: 0.2,
// Whether the camera is rotated along with the device.
followRotation: true/false,
// The callback when a barcode is scanned
onBarcodeScanned: (barcode) {
},
// Custom ui for building requesting permissions and loading screens.
// Build your own by extending the BarcodeKitUiBuilder
uiBuilder: BarcodeKitUiBuilder(),
)
Barcode Formats
The formats
parameter is a list of barcode formats to scan. The supported formats are:
Format | iOS | Android |
---|---|---|
AZTEC | ✅ | ✅ |
CODABAR | ❌ | ✅ |
CODE39 | ✅ | ✅ |
CODE93 | ✅ | ✅ |
CODE128 | ✅ | ✅ |
DATAM ATRIX | ✅ | ✅ |
EAN8 | ✅ | ✅ |
EAN13 | ✅ | ✅ |
ITF | ✅ | ✅ |
PDF417 | ✅ | ✅ |
QR-CODE | ✅ | ✅ |
UPCA | ❌ | ✅ |
UPCE | ✅ | ✅ |
Contributing
We welcome contributions! Please fork the repository and submit a pull request with your changes. Ensure that your code adheres to our coding standards and includes appropriate tests.
License
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.