Open elmar001 opened 1 year ago
Found the solution for preventing this issue. Commenting out overlay: QrScannerOverlayShape from the QRView solves the issue but there will be no overlay (Possible to create replacement dummy overlay with Stack widget if necessary):
Replacing this: Widget _buildQrView(BuildContext context) { // For this example we check how width or tall the device is and change the scanArea and overlay accordingly. var scanArea = (MediaQuery.of(context).size.width < 400 || MediaQuery.of(context).size.height < 400) ? 150.0 : 300.0; return QRView( key: qrKey, onQRViewCreated: _onQRViewCreated, overlay: QrScannerOverlayShape( borderColor: Colors.blue, borderRadius: 10, borderLength: 30, borderWidth: 10, cutOutSize: scanArea ), ); }
With this: Widget _buildQrView(BuildContext context) { // For this example we check how width or tall the device is and change the scanArea and overlay accordingly. var scanArea = (MediaQuery.of(context).size.width < 400 || MediaQuery.of(context).size.height < 400) ? 150.0 : 300.0; return QRView( key: qrKey, onQRViewCreated: _onQRViewCreated, // overlay: QrScannerOverlayShape( // borderColor: Colors.blue, // borderRadius: 10, // borderLength: 30, // borderWidth: 10, // cutOutSize: scanArea // ), ); }
you can do something like this (in your buisnise logic file AKA viewModel) declare function like this Future
In some cases when QR code scanner used camera view comes blank - kind of grey backgorund view and app stops working. I can see this exception thrown from Xcode debug run:
2022-10-19 10:14:06.445143+1000 Runner[12788:3739347] Assertion failure in -[MTBBarcodeScanner setScanRect:], MTBBarcodeScanner.m:973 2022-10-19 10:14:06.446678+1000 Runner[12788:3739347] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Scan rect cannot be set when not (yet) scanning. You may want to set it within didStartScanningBlock.' First throw call stack: (0x1cbbf2248 0x1c4fbfa68 0x1c657e81c 0x101cd0cbc 0x1021b2e34 0x1021b30dc 0x101cccf0c 0x10233c598 0x10233e04c 0x10234e800 0x10234e344 0x1cbc82a08 0x1cbc64368 0x1cbc691e4 0x204a89368 0x1ce118d88 0x1ce1189ec 0x1009d4bfc 0x1e9f8d948) libc++abi: terminating with uncaught exception of type NSException Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Scan rect cannot be set when not (yet) scanning. You may want to set it within didStartScanningBlock.' terminating with uncaught exception of type NSException (lldb)