更新为3.0.0后出现Flutter条码扫描错误

问题描述 投票:0回答:1

在我的Flutter应用程序中,我将barcode_scan软件包更新为版本3.0.0,并且出现以下错误:

E / libc(11783):访问被拒绝,找不到属性“ vendor.camera.hal1.packagelist”]

扫描仪打开正常,一旦找到条形码,就会引发错误。相机权限在清单中设置。我也找到了this issue,但我不知道如何解决该问题。可能我应该回到以前的版本吗?我的代码如下:

  Future _scanFromCamera() async {

    var options = ScanOptions(
      autoEnableFlash: true,
      useCamera: -1, // default camera
      android: AndroidOptions(
          useAutoFocus: true,
        ),
    );

    try {
      scanResult = await BarcodeScanner.scan(options: options);
      setState(() {
        print(scanResult.rawContent);
        this.barcode = scanResult.rawContent;
      });
      _showAlert(scanResult.rawContent);
    } on PlatformException catch (e) {
      if (e.code == BarcodeScanner.cameraAccessDenied) {
        setState(() {
          this.barcode = 'The user did not grant the camera permission!';
        });
      } else {
        setState(() => this.barcode = 'Unknown error: $e');
      }
    } on FormatException {
      setState(() => this.barcode = 'null (User returned using the "back"-button before scanning anything. Result)');
    } catch (e) {
      setState(() => this.barcode = 'Unknown error: $e');
    }
  }

UPDATE我只是发现该错误也出现在条形码_scan:2.0.2版本中,但是扫描工作正常。因此,版本3的原因可能是另一个原因。

flutter
1个回答
0
投票

我有同样的问题:

© www.soinside.com 2019 - 2024. All rights reserved.