Преглед изворни кода

Added possibility to choose facing camera on start.

Moved the size listener to plugin side.
flutter-beta
Julian Steenbakker пре 5 година
родитељ
комит
f3b3452570
No known key found for this signature in database GPG Key ID: 16E437C7A3D94250
1 измењених фајлова са 8 додато и 13 уклоњено
  1. +8
    -13
      lib/src/qr_code_scanner.dart

+ 8
- 13
lib/src/qr_code_scanner.dart Прегледај датотеку

@@ -132,8 +132,8 @@ class _QRViewState extends State<QRView> {
_channel = MethodChannel('net.touchcapture.qr.flutterqr/qrview_$id'); _channel = MethodChannel('net.touchcapture.qr.flutterqr/qrview_$id');


// Start scan after creation of the view // 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); .._startScan(widget.key, cutOutSize, widget.formatsAllowed);


// Initialize the controller for controlling the QRView // Initialize the controller for controlling the QRView
@@ -158,12 +158,9 @@ class _QrCameraSettings {
} }


class QRViewController { 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 { _channel.setMethodCallHandler((call) async {
switch (call.method) { switch (call.method) {
case 'onRecognizeQR': case 'onRecognizeQR':
@@ -212,14 +209,12 @@ class QRViewController {
bool get hasPermissions => _hasPermissions; bool get hasPermissions => _hasPermissions;


/// Starts the barcode scanner /// Starts the barcode scanner
Future<void> _startScan(
GlobalKey key,
double cutOutSize,
Future<void> _startScan(GlobalKey key, double cutOutSize,
List<BarcodeFormat> barcodeFormats) async { List<BarcodeFormat> barcodeFormats) async {
// We need to update the dimension before the scan is started. // We need to update the dimension before the scan is started.
QRViewController.updateDimensions(key, _channel, scanArea: cutOutSize); 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. /// Gets information about which camera is active.


Loading…
Откажи
Сачувај