Showing
1 changed file
with
7 additions
and
0 deletions
| @@ -180,6 +180,13 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan | @@ -180,6 +180,13 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan | ||
| 180 | device = AVCaptureDevice.devices(for: .video).filter({$0.position == position}).first | 180 | device = AVCaptureDevice.devices(for: .video).filter({$0.position == position}).first |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | + if (device == nil) { | ||
| 184 | + result(FlutterError(code: "MobileScanner", | ||
| 185 | + message: "No camera found or failed to open camera!", | ||
| 186 | + details: nil)) | ||
| 187 | + return | ||
| 188 | + } | ||
| 189 | + | ||
| 183 | // Enable the torch if parameter is set and torch is available | 190 | // Enable the torch if parameter is set and torch is available |
| 184 | if (device.hasTorch && device.isTorchAvailable) { | 191 | if (device.hasTorch && device.isTorchAvailable) { |
| 185 | do { | 192 | do { |
-
Please register or login to post a comment