Navaron Bracke
Committed by GitHub

Merge pull request #831 from navaronbracke/fix_scan_window_completion

fix: fix updateScanWindow() not completing on Android and MacOS
  1 +## NEXT
  2 +Bugs fixed:
  3 +* Fixed the `updateScanWindow()` function not completing on Android and MacOS. (thanks @navaronbracke !)
  4 +
1 ## 3.5.1 5 ## 3.5.1
2 Improvements: 6 Improvements:
3 * The `type` of an `Address` is now non-null. 7 * The `type` of an `Address` is now non-null.
@@ -123,7 +123,7 @@ class MobileScannerHandler( @@ -123,7 +123,7 @@ class MobileScannerHandler(
123 "analyzeImage" -> analyzeImage(call, result) 123 "analyzeImage" -> analyzeImage(call, result)
124 "setScale" -> setScale(call, result) 124 "setScale" -> setScale(call, result)
125 "resetScale" -> resetScale(result) 125 "resetScale" -> resetScale(result)
126 - "updateScanWindow" -> updateScanWindow(call) 126 + "updateScanWindow" -> updateScanWindow(call, result)
127 else -> result.notImplemented() 127 else -> result.notImplemented()
128 } 128 }
129 } 129 }
@@ -263,7 +263,9 @@ class MobileScannerHandler( @@ -263,7 +263,9 @@ class MobileScannerHandler(
263 } 263 }
264 } 264 }
265 265
266 - private fun updateScanWindow(call: MethodCall) { 266 + private fun updateScanWindow(call: MethodCall, result: MethodChannel.Result) {
267 mobileScanner!!.scanWindow = call.argument<List<Float>?>("rect") 267 mobileScanner!!.scanWindow = call.argument<List<Float>?>("rect")
  268 +
  269 + result.success(null)
268 } 270 }
269 } 271 }
@@ -66,7 +66,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -66,7 +66,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
66 case "stop": 66 case "stop":
67 stop(result) 67 stop(result)
68 case "updateScanWindow": 68 case "updateScanWindow":
69 - updateScanWindow(call) 69 + updateScanWindow(call, result)
70 default: 70 default:
71 result(FlutterMethodNotImplemented) 71 result(FlutterMethodNotImplemented)
72 } 72 }
@@ -187,11 +187,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -187,11 +187,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
187 } 187 }
188 } 188 }
189 189
190 - func updateScanWindow(_ call: FlutterMethodCall) { 190 + func updateScanWindow(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
191 let argReader = MapArgumentReader(call.arguments as? [String: Any]) 191 let argReader = MapArgumentReader(call.arguments as? [String: Any])
192 let scanWindowData: Array? = argReader.floatArray(key: "rect") 192 let scanWindowData: Array? = argReader.floatArray(key: "rect")
193 193
194 if (scanWindowData == nil) { 194 if (scanWindowData == nil) {
  195 + result(nil)
195 return 196 return
196 } 197 }
197 198
@@ -202,6 +203,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -202,6 +203,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
202 let height = scanWindowData![3] - minY 203 let height = scanWindowData![3] - minY
203 204
204 scanWindow = CGRect(x: minX, y: minY, width: width, height: height) 205 scanWindow = CGRect(x: minX, y: minY, width: width, height: height)
  206 + result(nil)
205 } 207 }
206 208
207 func isBarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: VNBarcodeObservation, _ inputImage: CGImage) -> Bool { 209 func isBarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: VNBarcodeObservation, _ inputImage: CGImage) -> Bool {