Showing
1 changed file
with
6 additions
and
2 deletions
| @@ -320,7 +320,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -320,7 +320,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 320 | 320 | ||
| 321 | // TODO: this method should be removed when iOS and MacOS share their implementation. | 321 | // TODO: this method should be removed when iOS and MacOS share their implementation. |
| 322 | private func toggleTorchInternal(_ torch: AVCaptureDevice.TorchMode) throws { | 322 | private func toggleTorchInternal(_ torch: AVCaptureDevice.TorchMode) throws { |
| 323 | - if (device == nil || !device.hasTorch) { | 323 | + guard let device = self.device else { |
| 324 | + return | ||
| 325 | + } | ||
| 326 | + | ||
| 327 | + if (!device.hasTorch || !device.isTorchModeSupported(torch)) { | ||
| 324 | return | 328 | return |
| 325 | } | 329 | } |
| 326 | 330 | ||
| @@ -337,7 +341,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | @@ -337,7 +341,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, | ||
| 337 | } | 341 | } |
| 338 | } | 342 | } |
| 339 | 343 | ||
| 340 | - func toggleTorch(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { | 344 | + private func toggleTorch(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { |
| 341 | let requestedTorchMode: AVCaptureDevice.TorchMode = call.arguments as! Int == 1 ? .on : .off | 345 | let requestedTorchMode: AVCaptureDevice.TorchMode = call.arguments as! Int == 1 ? .on : .off |
| 342 | 346 | ||
| 343 | do { | 347 | do { |
-
Please register or login to post a comment