qr_code_scanner_ohos 1.0.0 copy "qr_code_scanner_ohos: ^1.0.0" to clipboard
qr_code_scanner_ohos: ^1.0.0 copied to clipboard

QR code scanner that can be embedded inside flutter. It uses zxing in Ohos.

qr_code_scanner_ohos #

A QR code scanner that works on ohos by natively embedding the platform view within Flutter. The integration with Flutter is seamless, much better than jumping into a native Activity or a ViewController to perform the scan.

Get Scanned QR Code #

When a QR code is recognized, the text identified will be set in 'result' of type Barcode, which contains the output text as property 'code' of type String and scanned code type as property 'format' which is an enum BarcodeFormat, defined in the library.

Usage #

  yaml
    dependencies:
      qr_code_scanner: 1.0.0
      qr_code_scanner_ohos: 1.0.0
class _QRViewExampleState extends State<QRViewExample> {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  Barcode? result;
  QRViewController? controller;

  // In order to get hot reload to work we need to pause the camera if the platform
  @override
  void reassemble() {
    super.reassemble();
    if (defaultTargetPlatform == TargetPlatform.ohos) {
      controller!.pauseCamera();
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Expanded(
            flex: 5,
            child: QRView(
              key: qrKey,
              onQRViewCreated: _onQRViewCreated,
            ),
          ),
          Expanded(
            flex: 1,
            child: Center(
              child: (result != null)
                  ? Text(
                      'Barcode Type: ${describeEnum(result!.format)}   Data: ${result!.code}')
                  : Text('Scan a code'),
            ),
          )
        ],
      ),
    );
  }

  void _onQRViewCreated(QRViewController controller) {
    this.controller = controller;
    controller.scannedDataStream.listen((scanData) {
      setState(() {
        result = scanData;
      });
    });
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }
}

0
likes
60
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

QR code scanner that can be embedded inside flutter. It uses zxing in Ohos.

Repository

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter, flutter_web_plugins, js, plugin_platform_interface

More

Packages that depend on qr_code_scanner_ohos

Packages that implement qr_code_scanner_ohos