Null when user cancelled the scan using Back Button
alvinvin00 opened this issue · 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 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
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.
what if user cancels QR Scanning process? Should scan method return null in that case?
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.
Check out this https://pub.dev/packages/barcode_scan_fix.
I have tried adding the scan function inside try-catch. But still, it fails. So, can you add try-catch in the function?
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.
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
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