detect method

  1. @override
void detect(
  1. DetectableImage image,
  2. bool streamed
)
override

Implementation

@override
void detect(DetectableImage image, bool streamed) async {
  if (!busy) {
    busy = true;

    count++;

    // get the detector
    var detector = await BarcodeDetector().getDetector();

    // detect in image
    var payload = await detector.detect(image, barcodeFormats, tryharder, invert);

    if (payload != null) {
      Data data = Payload.toData(payload);
      await onDetected(data);
    } else if (!streamed) {
      await onDetectionFailed(Data(data: [
        {
          "message":
              "Barcode detector $id failed to detect any barcodes in the supplied image"
        }
      ]));
    }
    busy = false;
  }
}