qrcode_scanner icon indicating copy to clipboard operation
qrcode_scanner copied to clipboard

Null when user cancelled the scan using Back Button

Open alvinvin00 opened this issue 4 years ago • 9 comments

Hello there, i'm having some problems that

~~a. If user are pressing Back Button (hardware), Null will be returned instead, the problem is scan method expects Future<String> which means anything that nullable will throw NullError.~~ (EDIT : Solved in 0.3.2)

b. If user are pressing Back Button (software, available on ZKing's platform view), the future will never complete

alvinvin00 avatar Jun 02 '21 07:06 alvinvin00

Yes problem b. is very serius. I am having this problem in which I need to return String and when I press back button it will stuck forever. Only solution for android is remove back button because we have hardware back button or software back button, if ios we need to throw error and catch it after that return something.

MerdanDev avatar Jun 06 '21 16:06 MerdanDev

what if user cancels QR Scanning process? Should scan method return null in that case?

alvinvin00 avatar Jun 08 '21 14:06 alvinvin00

I think it will throw error. After that we can catch error and we can show that user cancelled scanning or we can check is it null.

MerdanDev avatar Jun 08 '21 17:06 MerdanDev

Check out this https://pub.dev/packages/barcode_scan_fix.

mmkumr avatar Jun 13 '21 09:06 mmkumr

bruh, that package are not null-safe

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: M. Mukesh Kumar @.> Sent: Sunday, June 13, 2021 4:39:07 PM To: leyan95/qrcode_scanner @.> Cc: Alvin Leonardo @.>; Author @.> Subject: Re: [leyan95/qrcode_scanner] Null when user cancelled the scan using Back Button (#109)

Check out this https://pub.dev/packages/barcode_scan_fix.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/leyan95/qrcode_scanner/issues/109#issuecomment-860182236, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKUCEFP65W23NOMGTNNTNNTTSR4DXANCNFSM456GQNFQ.

alvinvin00 avatar Jun 13 '21 10:06 alvinvin00

I have tried adding the scan function inside try-catch. But still, it fails. So, can you add try-catch in the function?

mmkumr avatar Jun 13 '21 11:06 mmkumr

I have tried adding the scan function inside try-catch. But still, it fails. So, can you add try-catch in the function?

Can you show your code please? Yes it is possible to add try-catch in the function.

MerdanDev avatar Jun 22 '21 11:06 MerdanDev

I have tried adding the scan function inside try-catch. But still, it fails. So, can you add try-catch in the function?

try {
    //Scan QR Code
    code = await _qr.scanFromCamera();
} on TypeError {
    //Catch that pesky null thrown from library and do whatever the heck you want
}

This is what i did to deal with them

alvinvin00 avatar Jun 23 '21 07:06 alvinvin00

so, as of 0.3.2, problem A has been solved but problem B are still there, the soft back button wasn't removed in the latest release

alvinvin00 avatar Jun 25 '21 08:06 alvinvin00