【问题标题】:Flutter - How to scan QR code with front camera?Flutter - 如何用前置摄像头扫描二维码?
【发布时间】:2019-04-20 06:12:42
【问题描述】:

我希望能够使用前置摄像头扫描我的应用程序中的二维码,但所有可用插件仅支持主摄像头并且没有任何从前置摄像头捕获的选项,是否有任何解决此问题的方法主要吗?

【问题讨论】:

标签: dart flutter flutter-dependencies


【解决方案1】:

您可以在扫描功能的选项中进行配置:

Future scan() async {
    print("Scanning!!!");
    try {
      String barcode = await BarcodeScanner.scan(
        options: ScanOptions(
          useCamera: 1,
        )
      ).then((value) { return value.rawContent;});
      setState(() => this.barcode = barcode);
    }  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');
      }
    } 
  }

在ScanOptions的useCamera属性中使用数字1表示前置摄像头。

希望对你有帮助。

【讨论】:

  • 这个用的是哪个包?
猜你喜欢
  • 2020-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多