Navaron Bracke

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

... ... @@ -232,7 +232,6 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
device.activeFormat.formatDescription)
let hasTorch = device.hasTorch
DispatchQueue.main.async {
completion(
MobileScannerStartParameters(
width: Double(dimensions.height),
... ... @@ -241,16 +240,13 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
textureId: self.textureId ?? 0
)
)
}
return
}
DispatchQueue.main.async {
completion(MobileScannerStartParameters())
}
}
}
/// Stop scanning for barcodes
func stop() throws {
... ...
... ... @@ -121,7 +121,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
do {
try mobileScanner.start(barcodeScannerOptions: barcodeOptions, returnImage: returnImage, cameraPosition: position, torch: torch ? .on : .off, detectionSpeed: detectionSpeed) { parameters in
result(["textureId": parameters.textureId, "size": ["width": parameters.width, "height": parameters.height], "torchable": parameters.hasTorch])
DispatchQueue.main.async {
result([
"textureId": parameters.textureId,
"size": ["width": parameters.width, "height": parameters.height],
"torchable": parameters.hasTorch])
}
}
} catch MobileScannerError.alreadyStarted {
result(FlutterError(code: "MobileScanner",
... ...