# detectBarcodesOnImage static method

Future<BarcodeScanningResult> detectBarcodesOnImage(

1. Uri file,
2. List<BarcodeFormat> barcodeFormats,
3. {List<BarcodeDocumentFormat> acceptedDocumentFormats = const <BarcodeDocumentFormat>[]}

)

Detect barcodes from image file uri The Barcode Scanner is able to recognize 1D- and 2D-barcodes (QR codes, etc). `barcodeFormats` Format of barcode which need to recognize `acceptedDocumentFormats` Format of document which need to recognize

## Implementation

    static Future<BarcodeScanningResult> detectBarcodesOnImage(
      Uri file,
      List<BarcodeFormat> barcodeFormats, {
      List<BarcodeDocumentFormat> acceptedDocumentFormats =
          const <BarcodeDocumentFormat>[],
    }) async {
      var barcodeResult = BarcodeScanningResult.error(
          "Barcode detection failed"); // default error message initialisation
      try {
        List<Uri> list = [file];
        var result = await detectBarcodesOnImages(
          list,
          barcodeFormats,
          acceptedDocumentFormats: acceptedDocumentFormats,
        );
        if (result.operationResult == OperationResult.SUCCESS) {
          if (result.barcodeResults.isNotEmpty) {
            barcodeResult = result.barcodeResults.first;
          }
        } else {
          barcodeResult.message = result.message;
        }
        return barcodeResult;
      } catch (e) {
        Logger.root.severe(e);
        barcodeResult.message = e.toString();
        return barcodeResult;
      }
    }