Showing
2 changed files
with
9 additions
and
7 deletions
| @@ -133,7 +133,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | @@ -133,7 +133,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | ||
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /// Start scanning for barcodes | 135 | /// Start scanning for barcodes |
| 136 | - func start(barcodeScannerOptions: BarcodeScannerOptions?, returnImage: Bool, cameraPosition: AVCaptureDevice.Position, torch: AVCaptureDevice.TorchMode, detectionSpeed: DetectionSpeed, completion: @escaping (MobileScannerStartParameters) -> ()) throws { | 136 | + func start(barcodeScannerOptions: BarcodeScannerOptions?, returnImage: Bool, cameraPosition: AVCaptureDevice.Position, torch: Boolean, detectionSpeed: DetectionSpeed, completion: @escaping (MobileScannerStartParameters) -> ()) throws { |
| 137 | self.detectionSpeed = detectionSpeed | 137 | self.detectionSpeed = detectionSpeed |
| 138 | if (device != nil) { | 138 | if (device != nil) { |
| 139 | throw MobileScannerError.alreadyStarted | 139 | throw MobileScannerError.alreadyStarted |
| @@ -216,11 +216,13 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | @@ -216,11 +216,13 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | ||
| 216 | 216 | ||
| 217 | // Turn on the flashlight if requested, | 217 | // Turn on the flashlight if requested, |
| 218 | // but after the capture session started. | 218 | // but after the capture session started. |
| 219 | - do { | ||
| 220 | - try self.toggleTorch(torch) | ||
| 221 | - } catch { | ||
| 222 | - // If the torch does not turn on, | ||
| 223 | - // continue with the capture session anyway. | 219 | + if (torch) { |
| 220 | + do { | ||
| 221 | + try self.toggleTorch(.on) | ||
| 222 | + } catch { | ||
| 223 | + // If the torch does not turn on, | ||
| 224 | + // continue with the capture session anyway. | ||
| 225 | + } | ||
| 224 | } | 226 | } |
| 225 | 227 | ||
| 226 | do { | 228 | do { |
| @@ -120,7 +120,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin { | @@ -120,7 +120,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin { | ||
| 120 | let detectionSpeed: DetectionSpeed = DetectionSpeed(rawValue: speed)! | 120 | let detectionSpeed: DetectionSpeed = DetectionSpeed(rawValue: speed)! |
| 121 | 121 | ||
| 122 | do { | 122 | do { |
| 123 | - try mobileScanner.start(barcodeScannerOptions: barcodeOptions, returnImage: returnImage, cameraPosition: position, torch: torch ? .on : .off, detectionSpeed: detectionSpeed) { parameters in | 123 | + try mobileScanner.start(barcodeScannerOptions: barcodeOptions, returnImage: returnImage, cameraPosition: position, torch: torch, detectionSpeed: detectionSpeed) { parameters in |
| 124 | DispatchQueue.main.async { | 124 | DispatchQueue.main.async { |
| 125 | result([ | 125 | result([ |
| 126 | "textureId": parameters.textureId, | 126 | "textureId": parameters.textureId, |
-
Please register or login to post a comment