Showing
2 changed files
with
5 additions
and
3 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,12 +216,14 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | @@ -216,12 +216,14 @@ 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 | + if (torch) { | ||
| 219 | do { | 220 | do { |
| 220 | - try self.toggleTorch(torch) | 221 | + try self.toggleTorch(.on) |
| 221 | } catch { | 222 | } catch { |
| 222 | // If the torch does not turn on, | 223 | // If the torch does not turn on, |
| 223 | // continue with the capture session anyway. | 224 | // continue with the capture session anyway. |
| 224 | } | 225 | } |
| 226 | + } | ||
| 225 | 227 | ||
| 226 | do { | 228 | do { |
| 227 | try self.resetScale() | 229 | try self.resetScale() |
| @@ -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