Barcode Kit
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 widet that handles most of the work for you.
Pre-requisites
Make sure you have flutter installed and have configured a Flutter project. You can find more information on how to set up a Flutter project in the official Flutter documentation.
Installation
Add the barcode kit to your to your pubspec.yaml
file:
flutter pub add mtrust_barcode_kit
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: