瀏覽代碼

add invert scan feature for android

flutter-beta
Akshay Kalbhor 4 年之前
父節點
當前提交
4455cf8302
共有 2 個文件被更改,包括 21 次插入0 次删除
  1. +9
    -0
      android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt
  2. +12
    -0
      lib/src/qr_code_scanner.dart

+ 9
- 0
android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt 查看文件

@@ -90,6 +90,7 @@ class QRView(private val context: Context, messenger: BinaryMessenger, private v
call.argument<Double>("cutOutBottomOffset")!!,
result,
)
"invertScan" -> setInvertScan(call.argument<Boolean>("isInvertScan")!!, result)
else -> result.notImplemented()
}
}
@@ -259,6 +260,14 @@ class QRView(private val context: Context, messenger: BinaryMessenger, private v
result.success(true)
}

private fun setInvertScan(isInvert: Boolean, result: MethodChannel.Result) {
barcodeView!!.pause()
val settings = barcodeView!!.cameraSettings
settings.isScanInverted = isInvert
barcodeView!!.cameraSettings = settings
barcodeView!!.resume();
}

private fun setScanAreaSize(
dpScanAreaWidth: Double,
dpScanAreaHeight: Double,


+ 12
- 0
lib/src/qr_code_scanner.dart 查看文件

@@ -357,4 +357,16 @@ class QRViewController {
}
return false;
}

//Starts/Stops invert scanning.
Future<void> scanInvert(bool isScanInvert) async {
if (defaultTargetPlatform == TargetPlatform.android) {
try {
await _channel
.invokeMethod('invertScan', {"isInvertScan": isScanInvert});
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
}
}
}

Loading…
取消
儲存