From 2938eda4c7a09f8d344e969880825b75107f860f Mon Sep 17 00:00:00 2001 From: Navaron Bracke Date: Wed, 25 Oct 2023 08:41:13 +0200 Subject: [PATCH] fix updateScanWindow() not completing on Android and MacOS --- CHANGELOG.md | 4 ++++ .../dev/steenbakker/mobile_scanner/MobileScannerHandler.kt | 6 ++++-- macos/Classes/MobileScannerPlugin.swift | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06eda0e03..d93014952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT +Bugs fixed: +* Fixed the `updateScanWindow()` function not completing on Android and MacOS. (thanks @navaronbracke !) + ## 3.5.1 Improvements: * The `type` of an `Address` is now non-null. diff --git a/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt b/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt index 88a9389cb..443d716db 100644 --- a/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt +++ b/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt @@ -123,7 +123,7 @@ class MobileScannerHandler( "analyzeImage" -> analyzeImage(call, result) "setScale" -> setScale(call, result) "resetScale" -> resetScale(result) - "updateScanWindow" -> updateScanWindow(call) + "updateScanWindow" -> updateScanWindow(call, result) else -> result.notImplemented() } } @@ -263,7 +263,9 @@ class MobileScannerHandler( } } - private fun updateScanWindow(call: MethodCall) { + private fun updateScanWindow(call: MethodCall, result: MethodChannel.Result) { mobileScanner!!.scanWindow = call.argument?>("rect") + + result.success(null) } } diff --git a/macos/Classes/MobileScannerPlugin.swift b/macos/Classes/MobileScannerPlugin.swift index 86fa5af90..d64d4fa0c 100644 --- a/macos/Classes/MobileScannerPlugin.swift +++ b/macos/Classes/MobileScannerPlugin.swift @@ -66,7 +66,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, case "stop": stop(result) case "updateScanWindow": - updateScanWindow(call) + updateScanWindow(call, result) default: result(FlutterMethodNotImplemented) } @@ -187,11 +187,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, } } - func updateScanWindow(_ call: FlutterMethodCall) { + func updateScanWindow(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { let argReader = MapArgumentReader(call.arguments as? [String: Any]) let scanWindowData: Array? = argReader.floatArray(key: "rect") if (scanWindowData == nil) { + result(nil) return } @@ -202,6 +203,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, let height = scanWindowData![3] - minY scanWindow = CGRect(x: minX, y: minY, width: width, height: height) + result(nil) } func isBarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: VNBarcodeObservation, _ inputImage: CGImage) -> Bool {