From f3b3452570e24a0f11706384624992b93e850bf8 Mon Sep 17 00:00:00 2001 From: Julian Steenbakker Date: Sun, 10 Jan 2021 21:54:53 +0100 Subject: [PATCH] Added possibility to choose facing camera on start. Moved the size listener to plugin side. --- lib/src/qr_code_scanner.dart | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/src/qr_code_scanner.dart b/lib/src/qr_code_scanner.dart index bb509e7..eec48b1 100644 --- a/lib/src/qr_code_scanner.dart +++ b/lib/src/qr_code_scanner.dart @@ -132,8 +132,8 @@ class _QRViewState extends State { _channel = MethodChannel('net.touchcapture.qr.flutterqr/qrview_$id'); // Start scan after creation of the view - final controller = QRViewController._(_channel, widget.key, cutOutSize, - widget.onPermissionSet) + final controller = QRViewController._( + _channel, widget.key, cutOutSize, widget.onPermissionSet) .._startScan(widget.key, cutOutSize, widget.formatsAllowed); // Initialize the controller for controlling the QRView @@ -158,12 +158,9 @@ class _QrCameraSettings { } class QRViewController { - QRViewController._( - MethodChannel channel, - GlobalKey qrKey, - double scanArea, - PermissionSetCallback onPermissionSet - ) : _channel = channel { + QRViewController._(MethodChannel channel, GlobalKey qrKey, double scanArea, + PermissionSetCallback onPermissionSet) + : _channel = channel { _channel.setMethodCallHandler((call) async { switch (call.method) { case 'onRecognizeQR': @@ -212,14 +209,12 @@ class QRViewController { bool get hasPermissions => _hasPermissions; /// Starts the barcode scanner - Future _startScan( - GlobalKey key, - double cutOutSize, + Future _startScan(GlobalKey key, double cutOutSize, List barcodeFormats) async { // We need to update the dimension before the scan is started. QRViewController.updateDimensions(key, _channel, scanArea: cutOutSize); - return _channel.invokeMethod('startScan', - barcodeFormats?.map((e) => e.asInt())?.toList() ?? []); + return _channel.invokeMethod( + 'startScan', barcodeFormats?.map((e) => e.asInt())?.toList() ?? []); } /// Gets information about which camera is active.