繁体   English   中英

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

[英]Flutter barcode_scan error after updating to 3.0.0

在我的 flutter 应用程序中,我将barcode_scan package 更新到版本 3.0.0,我收到以下错误:

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

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

  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');
    }
  }

更新我刚刚发现这个错误也出现在版本barcode_scan:2.0.2中,但扫描工作正常。 所以版本 3 的原因可能是另一个。

我有同样的问题:

  • 请将 flutter 版本更新到更新版本。
  • 然后按照以下说明操作: this

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM