Navaron Bracke

move the dispatch queue switch for the start completion block for readability

@@ -232,23 +232,19 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -232,23 +232,19 @@ 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(  
237 - MobileScannerStartParameters(  
238 - width: Double(dimensions.height),  
239 - height: Double(dimensions.width),  
240 - hasTorch: hasTorch,  
241 - textureId: self.textureId ?? 0  
242 - ) 235 + completion(
  236 + MobileScannerStartParameters(
  237 + width: Double(dimensions.height),
  238 + height: Double(dimensions.width),
  239 + hasTorch: hasTorch,
  240 + textureId: self.textureId ?? 0
243 ) 241 )
244 - } 242 + )
245 243
246 return 244 return
247 } 245 }
248 246
249 - DispatchQueue.main.async {  
250 - completion(MobileScannerStartParameters())  
251 - } 247 + completion(MobileScannerStartParameters())
252 } 248 }
253 } 249 }
254 250
@@ -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",