google_mlkit_barcode_scanning 0.2.0 google_mlkit_barcode_scanning: ^0.2.0 copied to clipboard
A Flutter plugin to use Google's ML Kit Barcode Scanning to read data encoded using most standard barcode formats.
Google's ML Kit Barcode Scanning for Flutter #
A Flutter plugin to use Google's ML Kit Barcode Scanning to read data encoded using most standard barcode formats.
Getting Started #
Before you get started read about the requirements and known issues of this plugin here.
Usage #
Barcode scanning #
Create an instance of InputImage
Create an instance of InputImage
as explained here.
final InputImage inputImage;
Create an instance of BarcodeScanner
final List<BarcodeFormat> formats = [BarcodeFormat.all, ...];
final barcodeScanner = BarcodeScanner(formats: formats);
Process image
final List<Barcode> barcodes = await barcodeScanner.processImage(inputImage);
for (Barcode barcode in barcodes) {
final BarcodeType type = barcode.type;
final Rect boundingBox = barcode.boundingBox;
final String displayValue = barcode.displayValue;
final String rawValue = barcode.rawValue;
// See API reference for complete list of supported types
switch (type) {
case BarcodeType.wifi:
BarcodeWifi barcodeWifi = barcode.value;
break;
case BarcodeValueType.url:
BarcodeUrl barcodeUrl = barcode.value;
break;
}
}
Release resources with close()
barcodeScanner.close();
Example app #
Find the example app here.
Contributing #
Contributions are welcome. In case of any problems look at existing issues, if you cannot find anything related to your problem then open an issue. Create an issue before opening a pull request for non trivial fixes. In case of trivial fixes open a pull request directly.