[英]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 的原因可能是另一個。
我有同樣的問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.