颤抖,“错误从相机读取”与qr_mobile_vision和ios

时间:2019-04-15 09:39:18

标签: ios dart flutter

几天前,我开始学习抖动,我想用条形码阅读器构建一个示例应用程序(bottomNavigationBar的第二个元素必须是我的条形码阅读器)

我已在各种条形码插件之间进行切换,但似乎没有一个可行的方法(我在安装软件包时应用崩溃了。)

无论如何,我发现(也许)一个很好的软件包:qr_mobile_vision。

我已经编写了这段代码:


class _ProductState extends State<Product> {
  String barcode = "";
  Container child;

  @override
  Widget build(BuildContext context) {
    int currentPage = 0;

    return new Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.white,
          elevation: 0.0,
          centerTitle: false,
          title: Text(
            'asdfasdf',
            textAlign: TextAlign.left,
          ),
        ),
        body: SingleChildScrollView(
          child: _getPage(currentPage),
        ),
        bottomNavigationBar: FancyBottomNavigation(
          tabs: [
            TabData(iconData: Icons.home, title: "Home"),
            TabData(iconData: Icons.search, title: "Search"),
            TabData(iconData: Icons.shopping_cart, title: "Basket")
          ],
          onTabChangedListener: (position) {
            setState(() {
              currentPage = position;
            });
            print(position);
          },
        ));
  }

  _getPage(int page) {
    switch (page) {
      case 1:
        return new Container(
          constraints: new BoxConstraints.loose(new Size(600, 600)),
          child: new QrCamera(qrCodeCallback: (code) {
            print(code);
          }),
        );
        break;
      default:
        return new Container(child: new Text('Others tab'));
    }
  }
}

但是当我使用条形码阅读器转到标签(位置1)时,应用崩溃:

flutter: PlatformException(Error -11814, AVFoundationErrorDomain, Cannot Record)
flutter: Error reading from camera: PlatformException(Error -11814, AVFoundationErrorDomain, Cannot Record)
flutter: PlatformException(Error -11814, AVFoundationErrorDomain, Cannot Record)
flutter: Error reading from camera: PlatformException(Error -11814, AVFoundationErrorDomain, Cannot Record)
flutter: 1
flutter: 1
flutter: PlatformException(Error -11814, AVFoundationErrorDomain, Cannot Record)
flutter: Error reading from camera: PlatformException(Error -11814, AVFoundationErrorDomain, Cannot Record)

我还在info.plist中添加了“隐私-相机使用说明” ...

我不知道该怎么办,我真的很陌生,现在我被困住了……有什么帮助吗?

0 个答案:

没有答案