move the dispatch queue switch for the start completion block for readability
Showing
2 changed files
with
6 additions
and
5 deletions
| @@ -232,7 +232,6 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | @@ -232,7 +232,6 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | ||
| 232 | device.activeFormat.formatDescription) | 232 | device.activeFormat.formatDescription) |
| 233 | let hasTorch = device.hasTorch | 233 | let hasTorch = device.hasTorch |
| 234 | 234 | ||
| 235 | - DispatchQueue.main.async { | ||
| 236 | completion( | 235 | completion( |
| 237 | MobileScannerStartParameters( | 236 | MobileScannerStartParameters( |
| 238 | width: Double(dimensions.height), | 237 | width: Double(dimensions.height), |
| @@ -241,16 +240,13 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | @@ -241,16 +240,13 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega | ||
| 241 | textureId: self.textureId ?? 0 | 240 | textureId: self.textureId ?? 0 |
| 242 | ) | 241 | ) |
| 243 | ) | 242 | ) |
| 244 | - } | ||
| 245 | 243 | ||
| 246 | return | 244 | return |
| 247 | } | 245 | } |
| 248 | 246 | ||
| 249 | - DispatchQueue.main.async { | ||
| 250 | completion(MobileScannerStartParameters()) | 247 | completion(MobileScannerStartParameters()) |
| 251 | } | 248 | } |
| 252 | } | 249 | } |
| 253 | - } | ||
| 254 | 250 | ||
| 255 | /// Stop scanning for barcodes | 251 | /// Stop scanning for barcodes |
| 256 | func stop() throws { | 252 | func stop() throws { |
| @@ -121,7 +121,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin { | @@ -121,7 +121,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin { | ||
| 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 ? .on : .off, detectionSpeed: detectionSpeed) { parameters in |
| 124 | - result(["textureId": parameters.textureId, "size": ["width": parameters.width, "height": parameters.height], "torchable": parameters.hasTorch]) | 124 | + DispatchQueue.main.async { |
| 125 | + result([ | ||
| 126 | + "textureId": parameters.textureId, | ||
| 127 | + "size": ["width": parameters.width, "height": parameters.height], | ||
| 128 | + "torchable": parameters.hasTorch]) | ||
| 129 | + } | ||
| 125 | } | 130 | } |
| 126 | } catch MobileScannerError.alreadyStarted { | 131 | } catch MobileScannerError.alreadyStarted { |
| 127 | result(FlutterError(code: "MobileScanner", | 132 | result(FlutterError(code: "MobileScanner", |
-
Please register or login to post a comment