Skip to content

Not able to scan vertically but able to scan horizontally #166

@mishraaditya595

Description

@mishraaditya595

Description

When scanning certain barcodes, the scanner fails to detect them in portrait orientation. However, switching the phone to landscape orientation allows successful detection of the same barcodes.

Video Evidence

Video demonstration

Code Sample

String tempBarcodeValue = "-1";
String result = "-1";

await Navigator.of(context).push(
  MaterialPageRoute(
    builder: (context) => AiBarcodeScanner(
      setPortraitOrientation: false,
      galleryButtonType: GalleryButtonType.icon,
      // Validate the scanned barcode
      validator: (value) {
        debugPrint("Barcode detected: ${value.barcodes.first.rawValue}");
        return true;
      },
      onDetectError: (Object, StackTrace) {
        debugPrint("Barcode detected error");
      },
      onDetect: (BarcodeCapture capture) {
        // Handle the scanned barcode
        debugPrint("Barcode detected: ${capture.barcodes.first.rawValue}");
        result = capture.barcodes.first.rawValue ?? "-1";
        if (result != tempBarcodeValue) {
          Navigator.of(context).pop();
        } else {
          tempBarcodeValue = result;
        }
      },
    ),
  ),
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions