Closed ghost closed 4 years ago
hmm, not having that issue, did you get it resolved?
It's still happening with Flutter 1.9.1+hotfix.5 and iOS 13.1.3. This is my code:
01 try {
02 data = await BarcodeScanner.scan();
03 } on PlatformException catch ( e ) {
04 if ( e.code == BarcodeScanner.CameraAccessDenied ) {
05 scanResult.result = BarcodeReaderResultCode.CameraAccessDenied;
06 return scanResult;
07 }
08 else if ( e.code == BarcodeScanner.UserCanceled ) {
09 scanResult.result = BarcodeReaderResultCode.UserCancelled;
10 return scanResult;
11 }
12 else {
13 _log.warning( '$e' );
14 scanResult.result = BarcodeReaderResultCode.Error;
15 scanResult.data = e.toString();
16 return scanResult;
17 }
18 } on FormatException {
19 scanResult.result = BarcodeReaderResultCode.UserCancelled;
20 return scanResult;
21 }
22 catch ( e ) {
23 _log.warning( '$e' );
24 scanResult.result = BarcodeReaderResultCode.Error;
25 scanResult.data = e.toString();
26 return scanResult;
27 }
28
29 scanResult.result = BarcodeReaderResultCode.Ok;
30 scanResult.data = data;
31 return scanResult;
When pressing "cancel", a PlatformException is thrown and the code continues in line 9:
scanResult.result = BarcodeReaderResultCode.UserCancelled;
But if swiping down the code "hangs" in line 2 and the future never returns.
The desired fix may be to make the modalPresentationStyle to fullScreen, this was changed in iOS 13 (default value was changed)
if (@available(iOS 13.0, *)) {
[scannerViewController setModalPresentationStyle:UIModalPresentationFullScreen];
}
We made the change in our fork here for reference :https://github.com/bbedward/flutter_barcode_reader/commit/98869b04a546640f9652da1a6c5e7f1c0b209ba0
@appditto I tried your fork and on my device (iPhone 6s, ios 13.1.2) camera still shown as overlay, not full screen.
@mimokrok
Did you run packages upgrade after changing to the git URL?
We just tested the change and promoted it to production in two of our apps today.
@appditto
Yes I updated it.
I fixed it when I added this line of code in 'BarcodeScanPlugin.m':
[navigationController setModalPresentationStyle:UIModalPresentationFullScreen];
So finally this work for me:
- (void)showBarcodeView:(NSString *)theme {
BarcodeScannerViewController *scannerViewController = [[BarcodeScannerViewController alloc] initWithTheme:theme];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:scannerViewController];
if (@available(iOS 13.0, *)) {
[navigationController setModalPresentationStyle:UIModalPresentationFullScreen];
}
scannerViewController.delegate = self;
[self.hostViewController presentViewController:navigationController animated:NO completion:nil];
}
This working for me :
if (@available(iOS 13.0, *)) {
[navigationController setModalPresentationStyle:UIModalPresentationFullScreen];
}
Thanks @mimokrok. The fix will be included in the next release.
Since iOS SDK 13 the camera is visually popping up as an overlay. As in previous iOS versions you can cancel the scanning via the cancel button (which is working fine). Since iOS 13 you can also swipe it down for the same effect. When swiping down the issue is similar to #60: the future is not returning. So the calling Dart code doesn't recognize that the scanning was canceled.