Переглянути джерело

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);
}
}
}
}

Завантаження…
Відмінити
Зберегти