gpt4 book ai didi

android - 使用虚拟场景在 Android 模拟器中扫描条码

转载 作者:行者123 更新时间:2023-12-03 21:11:04 24 4
gpt4 key购买 nike

我正在使用 flutter_barcode_reader 开发一个 Flutter 项目插入。在物理 Android 设备上一切正常,但是当我尝试扫描相机中的二维码时,二维码扫描仪无法在模拟器上使用react virtual scene .

有没有办法在不使用网络摄像头或物理设备的情况下实现这一目标?

最佳答案

似乎 flutter_barcode_reader插件,不再可用。

Since there are many other libraries which provides more and betterfunctionality in barcode scanning, I decided to discontinue thedevelopment of this project.


只是为了专注于您关于使用模拟器扫描二维码的问题,我已经设法从虚拟场景中扫描二维码。
这是 sample app我用来模拟这个:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:barcode_scan/barcode_scan.dart';
import 'package:flutter/services.dart';

void main() => runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
));

class HomePage extends StatefulWidget {
@override
HomePageState createState() {
return new HomePageState();
}
}

class HomePageState extends State<HomePage> {
String result = "Hey there !";

Future _scanQR() async {
try {
String qrResult = await BarcodeScanner.scan();
setState(() {
result = qrResult;
});
} on PlatformException catch (ex) {
if (ex.code == BarcodeScanner.CameraAccessDenied) {
setState(() {
result = "Camera permission was denied";
});
} else {
setState(() {
result = "Unknown Error $ex";
});
}
} on FormatException {
setState(() {
result = "You pressed the back button before scanning anything";
});
} catch (ex) {
setState(() {
result = "Unknown Error $ex";
});
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("QR Scanner"),
),
body: Center(
child: Text(
result,
style: new TextStyle(fontSize: 30.0, fontWeight: FontWeight.bold),
),
),
floatingActionButton: FloatingActionButton.extended(
icon: Icon(Icons.camera_alt),
label: Text("Scan"),
onPressed: _scanQR,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
}
enter image description here
由于您没有提供示例,因此我无法判断问题出在插件还是实现上。也许您可以尝试 pub.dev 中提供的其他插件:
enter image description here

关于android - 使用虚拟场景在 Android 模拟器中扫描条码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54549008/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com