Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict duplicate barcode scanning #224

Open
sudheeshde opened this issue Nov 19, 2023 · 5 comments
Open

Restrict duplicate barcode scanning #224

sudheeshde opened this issue Nov 19, 2023 · 5 comments

Comments

@sudheeshde
Copy link

Hi,

Thanks for this awesome library. Is there any way to restrict the duplicate barcode scanning inbuilt in this library?

@rmtmckenzie
Copy link
Owner

Do you mean that the qrCodeCallback is being called more than once? I considered limiting that when creating the library, but decided against it as it is very easy to handle that in the code where you're receiving it - you can either call stop as soon as you receive the first barcode or keep a variable with the last received and ignore anything else. If you mean something else could you clarify?

@sudheeshde
Copy link
Author

Thanks for the reply. Yes, I meant the qrCodeCallback. I've handled it by checking against a list with the last scanned items. I was just curious whether the library has an inbuilt option for this. Anyway thanks for your clarification.

@sudheeshde
Copy link
Author

sudheeshde commented Nov 20, 2023

Hi @rmtmckenzie,

I have one more query that needs a clarification:

When I'm scanning a barcode repeatedly, sometimes it detects correctly sometimes shows different results, it may be off with just one digit if my barcode is an IMEI number with 14 or 15 digits. Is there any way we can control this behavior?
Please check below link to see what's happening while scanning:
https://1drv.ms/v/s!AgZeh_DlKYsUjZw2mdPKPuWlGwNLQw?e=03QaVO

@sudheeshde sudheeshde reopened this Nov 20, 2023
@rmtmckenzie
Copy link
Owner

Unfortunately that's a limitation of the underlying scanning libraries & the camera. Bumping up the resolution might help, but I think it still won't be 100% reliable. Unfortunately that's not something that's super well supported with the easy-to-use code that handles rotation etc at the moment, but you could theoretically use the underlying QrMobileVision class. Also, scanning from another device's screen is always going to be less reliable than from something like paper - the glare + pixels mess with the algorithm, so it might be worth checking on a printed item if that's what you'll be using in practice.

If it is going to be digital and if you have any control over the device where the barcode is displayed, I'd recommend seeing if you can use QR codes instead of barcodes as they're much more robust in a digital scanning context, especially with extra error correction turned on.

@lutfi-haslab
Copy link

here is mine:

 bool _screenOpened = false;

qrCodeCallback: (code) {
          if (!_screenOpened) {
            _screenOpened = true;
            if (isEMT10Format(code.toString())) {
              Navigator.push(
                context,
                CupertinoPageRoute(
                    builder: (context) => VerifierSuccessScreen(
                          screenClose: _screenWasClosed,
                        )),
              );
              context
                  .read<CertusBloc>()
                  .add(CodeVerification(dataQr: code.toString()));
            } else {
              print('Scanned QR code does not contain EMT 1.0 format');
            }
          }
        },

 void _screenWasClosed() {
    _screenOpened = false;
  }

and when back to scan screen, just invoke this:

 @override
 Widget build(BuildContext context) {
   return WillPopScope(
     onWillPop: () {
       Navigator.pop(context, false);
       screenClose();
       return Future.value(true);
     },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants