Showing
2 changed files
with
7 additions
and
6 deletions
| @@ -16,10 +16,9 @@ class _BarcodeScannerWithControllerState | @@ -16,10 +16,9 @@ class _BarcodeScannerWithControllerState | ||
| 16 | String? barcode; | 16 | String? barcode; |
| 17 | 17 | ||
| 18 | MobileScannerController controller = MobileScannerController( | 18 | MobileScannerController controller = MobileScannerController( |
| 19 | - torchEnabled: true, | ||
| 20 | - // formats: [BarcodeFormat.qrCode] | ||
| 21 | - // facing: CameraFacing.front, | ||
| 22 | - ); | 19 | + torchEnabled: true, formats: [BarcodeFormat.qrCode] |
| 20 | + // facing: CameraFacing.front, | ||
| 21 | + ); | ||
| 23 | 22 | ||
| 24 | bool isStarted = true; | 23 | bool isStarted = true; |
| 25 | 24 |
| @@ -178,8 +178,10 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan | @@ -178,8 +178,10 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan | ||
| 178 | formatList.add(BarcodeFormat(rawValue: index)) | 178 | formatList.add(BarcodeFormat(rawValue: index)) |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | - let barcodeOptions = BarcodeScannerOptions(formats: formatList.firstObject as! BarcodeFormat) | ||
| 182 | - scanner = BarcodeScanner.barcodeScanner(options: barcodeOptions) | 181 | + if (formatList.count != 0) { |
| 182 | + let barcodeOptions = BarcodeScannerOptions(formats: formatList.firstObject as! BarcodeFormat) | ||
| 183 | + scanner = BarcodeScanner.barcodeScanner(options: barcodeOptions) | ||
| 184 | + } | ||
| 183 | 185 | ||
| 184 | // Set the camera to use | 186 | // Set the camera to use |
| 185 | position = facing == 0 ? AVCaptureDevice.Position.front : .back | 187 | position = facing == 0 ? AVCaptureDevice.Position.front : .back |
-
Please register or login to post a comment