Julian Steenbakker

bug: fix crash on macOS when no camera is available

@@ -185,6 +185,13 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -185,6 +185,13 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
185 device = AVCaptureDevice.devices(for: .video).filter({$0.position == position}).first 185 device = AVCaptureDevice.devices(for: .video).filter({$0.position == position}).first
186 } 186 }
187 187
  188 + if (device == nil) {
  189 + result(FlutterError(code: "MobileScanner",
  190 + message: "No camera found!",
  191 + details: nil))
  192 + return
  193 + }
  194 +
188 // Enable the torch if parameter is set and torch is available 195 // Enable the torch if parameter is set and torch is available
189 if (device.hasTorch) { 196 if (device.hasTorch) {
190 do { 197 do {