mintware-de / flutter_barcode_reader

A flutter plugin for reading 2D barcodes and QR codes.
MIT License
628 stars 463 forks source link

[Bug] #234

Closed daveparks23 closed 4 years ago

daveparks23 commented 4 years ago

Describe the bug Android only. iOS works fine. The scan does not return anything.

To Reproduce Steps to reproduce the behavior: I trigger the scan function. The camera starts up and works fine. Once the barcode has been read the app returns to the screen where the data should appear. And there is no data. The code after

ScanResult result = await BarcodeScanner.scan(options: options);
setState(() => scanResult = result);
print('Gotaresultforbarcode');

The print never occurs in the console.

Expected behavior Scan a barcode or qr code and get a result.

Environment (please complete the following information):

Android LG Stylo 4

Future<String> _getBarcode() async {
    print('Get Barcode Started');
    try {
       var options = ScanOptions(
        strings: {
          "cancel": 'Cancel',
          "flash_on": 'Flash',
          "flash_off": 'Flash Off',
        },);
      ScanResult result = await BarcodeScanner.scan(options: options);
      setState(() => scanResult = result);
     print('Gotaresultforbarcode');
     return result.rawContent;
    } on PlatformException catch (e) {
      var result = ScanResult(
        type: ResultType.Error,
        format: BarcodeFormat.unknown,
      );

      if (e.code == BarcodeScanner.cameraAccessDenied) {
        setState(() {
          result.rawContent = 'The user did not grant the camera permission!';
        });

      } else {
        result.rawContent = 'Unknown error: $e';
      }
      setState(() {
        scanResult = result;
      });
      return result.rawContent;
    }   
  }

Additional context

Works on iOS. This bug only occurs on Android.
I cannot reproduce when using the example app. Thanks for any help.

devtronic commented 4 years ago

Not a bug. Dupe of #227

daveparks23 commented 4 years ago

Not a bug. Dupe of #227

Thank you for your help! #227 Got me going in the right direction! Problem resolved!