Skip to content

Commit 89a7b1e

Browse files
Merge pull request #459 from akkalbhor/feat-invert-scan
add invert scan feature for android
2 parents c1ef7b4 + 6589334 commit 89a7b1e

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class QRView(private val context: Context, messenger: BinaryMessenger, private v
9090
call.argument<Double>("cutOutBottomOffset")!!,
9191
result,
9292
)
93+
"invertScan" -> setInvertScan(call.argument<Boolean>("isInvertScan")!!, result)
9394
else -> result.notImplemented()
9495
}
9596
}
@@ -257,6 +258,14 @@ class QRView(private val context: Context, messenger: BinaryMessenger, private v
257258
result.success(true)
258259
}
259260

261+
private fun setInvertScan(isInvert: Boolean, result: MethodChannel.Result) {
262+
barcodeView!!.pause()
263+
val settings = barcodeView!!.cameraSettings
264+
settings.isScanInverted = isInvert
265+
barcodeView!!.cameraSettings = settings
266+
barcodeView!!.resume();
267+
}
268+
260269
private fun setScanAreaSize(
261270
dpScanAreaWidth: Double,
262271
dpScanAreaHeight: Double,

lib/src/qr_code_scanner.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,16 @@ class QRViewController {
357357
}
358358
return false;
359359
}
360+
361+
//Starts/Stops invert scanning.
362+
Future<void> scanInvert(bool isScanInvert) async {
363+
if (defaultTargetPlatform == TargetPlatform.android) {
364+
try {
365+
await _channel
366+
.invokeMethod('invertScan', {"isInvertScan": isScanInvert});
367+
} on PlatformException catch (e) {
368+
throw CameraException(e.code, e.message);
369+
}
370+
}
371+
}
360372
}

lib/src/web/flutter_qr_web.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ class QRViewControllerWeb implements QRViewController {
309309
// TODO: flash is simply not supported by JavaScipt
310310
return;
311311
}
312+
313+
@override
314+
Future<void> scanInvert(bool isScanInvert) {
315+
// TODO: implement scanInvert
316+
throw UnimplementedError();
317+
}
312318
}
313319

314320
Widget createWebQrView({onPlatformViewCreated, CameraFacing? cameraFacing}) =>

0 commit comments

Comments
 (0)