flutter - 条码崩溃无错误
问题描述
我正在使用 qrCode 扫描仪制作应用程序,当我在 iphone 上打开应用程序并触摸 qrCode 扫描按钮时,它会自动关闭,甚至不打开相机。我在 pubspec.yaml 中使用了barcode_scan,代码是:
String qrResult = "Not yet Scanned";
onPressed: () async {
String scaning = await BarcodeScanner.scan();
setState(() {
qrResult = scaning;
});
},
该应用程序是用颤振制作的
解决方案
scan() async {
try {
dynamic bar = await BarcodeScanner.scan();
if(bar != null && bar.isNotEmpty){
print(" scanning qrcode ------------------------ $barcode");
setState(() {
barcode = bar;
});
}} on PlatformException catch (e) {
setState(() => this.barcode = '');
} on FormatException{
setState(() => this.barcode = '');
} catch (e) {
setState(() => this.barcode = '');
}
}
推荐阅读
- angular - 从本地目录读取 csv 文件
- python - 为什么使用 Conda 虚拟环境时回溯不引用 Python 文件?
- ffmpeg - ffmpeg:无法将硬件编码器 h264_rkmpp 与软件解码的 ATSC OTA 传输一起使用
- ios - 使用 beginUpdates 重新加载 tableView 部分
- mysql - 在关系链接 Laravel 中调用枢轴模型方法
- python - 在 Docker 容器内 - python: 无法打开文件 './services/web/manage.py': [Errno 2] 没有这样的文件或目录
- sql - 根据标题将值相加
- c# - 按 Count 然后按字符串排序排序的字符串集列表
- c# - ASP.Net/C# 如何存储方法字符串返回以供以后在另一个方法中使用?
- javascript - TypeError:当结果为空时,this.state.candidate.map 不是函数