Q

qr_code_scanner_aurora

Flutter плагин для платформы ОС Аврора.

qr_code_scanner_aurora

Implementation of qr_code_scanner for Aurora OS.

Usage

This package is not an endorsed implementation of qr_code_scanner. Therefore, you have to include qr_code_scanner_aurora alongside qr_code_scanner as dependencies in your pubspec.yaml file.

*.desktop

Permissions=Camera

*.spec

%global __requires_exclude ^lib(yuv|ZXing|jpeg)\\.so.*$

BuildRequires: pkgconfig(glesv2)
BuildRequires: pkgconfig(streamcamera)

pubspec.yaml

dependencies:
  qr_code_scanner: ^1.0.1
  qr_code_scanner_aurora:
    git:
      url: https://developer.auroraos.ru/git/flutter/flutter-community-plugins/qr_code_scanner_aurora.git
      ref: aurora-0.0.1

*.dart

import 'package:qr_code_scanner_aurora/qr_code_scanner.dart';

Widget previewQr(BuildContext context) {
  // For this example we check how width or tall the device is and change the scanArea and overlay accordingly.
  var scanArea = (MediaQuery.of(context).size.width < 400 || MediaQuery.of(context).size.height < 400)
      ? 250.0
      : 350.0;
  return QRView(
    key: _globalKey,
    onQRViewCreated: _onQRViewCreated,
    overlay: QrScannerOverlayShape(
        borderColor: Colors.purple,
        borderRadius: 10,
        borderLength: 30,
        borderWidth: 10,
        cutOutSize: scanArea,
    ),
    onPermissionSet: (ctrl, p) => {
      // Error permission
      if (mounted && !p) {
        setState(() {
          _states = States.error;
        })
      }
    },
  );
}

/// Get controller and listen QR after init plugin
void _onQRViewCreated(QRViewController controller) {
  if (!mounted) return;
  setState(() {
    _controller = controller;
  });
  controller.scannedDataStream.listen((scanData) {
    if (!mounted) return;
    setState(() {
      debugPrint(scanData.toString());
    });
  });
}

The plugin was implemented via a dependency on the qr_code_scanner plugin. To support the Aurora OS platform, the qr_code_scanner.dart file was copied and modified, which can be found in the lib/plugin directory.