Przeglądaj źródła

Merge pull request #459 from akkalbhor/feat-invert-scan

add invert scan feature for android
flutter-beta
Julian Steenbakker 4 lat temu
committed by GitHub
rodzic
commit
89a7b1ed5b
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 27 dodań i 0 usunięć
  1. +9
    -0
      android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt
  2. +12
    -0
      lib/src/qr_code_scanner.dart
  3. +6
    -0
      lib/src/web/flutter_qr_web.dart

+ 9
- 0
android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt Wyświetl plik

@@ -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()
}
}
@@ -257,6 +258,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 Wyświetl plik

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

+ 6
- 0
lib/src/web/flutter_qr_web.dart Wyświetl plik

@@ -309,6 +309,12 @@ class QRViewControllerWeb implements QRViewController {
// TODO: flash is simply not supported by JavaScipt
return;
}

@override
Future<void> scanInvert(bool isScanInvert) {
// TODO: implement scanInvert
throw UnimplementedError();
}
}

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


Ładowanie…
Anuluj
Zapisz