juliuscanute / qr_code_scanner

QR Code Scanner for Flutter
BSD 2-Clause "Simplified" License
1.01k stars 788 forks source link

[FEATURE] Scanning with only the specified barcode formats #643

Open monsieurtanuki opened 1 year ago

monsieurtanuki commented 1 year ago

Is your feature request related to a problem? Please describe. There's a bug in zxing, preventing QR-code scans to be performed in android API 23 and lower (app crash). I've opened an PR about it, but I'm not sure it will be accepted eventually.

In my specific use-case, I don't care about QR codes, I just care about barcodes. But it looks like in qr_code_scanner, all barcode formats are tried, and then the not desired barcode formats are filtered out. It means that even if I say "just scan EAN13", the problematic QR-code scan will be run (and crash).

Beyond the fact that my app crashes (which bothers me, I admit), it means that the scan could be optimized by checking only the desired barcode formats and not all formats.

Describe the solution you'd like I'm not familiar with kotlin but what I managed to write as a test is something like that (in QRView.kt):

    private fun initBarCodeView(): CustomFramingRectBarcodeView {
        var barcodeView = barcodeView

        if (barcodeView == null) {
            barcodeView = CustomFramingRectBarcodeView(QrShared.activity).also {
                this.barcodeView = it
            }

// this is where I add my list of formats
            barcodeView.decoderFactory = DefaultDecoderFactory(mutableListOf(BarcodeFormat.EAN_8, BarcodeFormat.EAN_13), null, null, 2)
//...

Of course this barcode list should match widget.formatsAllowed in qr_code_scanner.dart, but as I've said I don't code in kotlin. But I'm sure it can be done ;)

BraveEvidence commented 1 year ago

This will help https://www.youtube.com/watch?v=w-n0jUrUtPI&list=PLQhQEGkwKZUqZC2QAp_u4ZAzqpsCCRvmM&index=10 https://www.youtube.com/watch?v=QpnVENc9dIA&list=PLQhQEGkwKZUqZC2QAp_u4ZAzqpsCCRvmM&index=11

monsieurtanuki commented 1 year ago

Hi @BraveEvidence! Could you be a little more specific? In the current issue I say I would like to use qr_code_scanner with only specified barcode formats. Where in the videos is that topic evoked?