添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
独立的长颈鹿  ·  javascript ...·  1 年前    · 
苦闷的墨镜  ·  c语言 获取时间戳-掘金·  2 年前    · 
仗义的青蛙  ·  Using Fetch - Web ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I get a `cannot open camera "0" without camera permission` Error when I try to open a camera to scan a QR code

Ask Question

I get a cannot open camera "0" without camera permission Error when I try to open a camera to scan a QR code.

I have a QR code scanner function that does not open the camera. The scanner screen appears but I do not see the box with the line inside for scanning.

I have also added camera permissions in the Android manifest

Android Manifest Permissions

 <uses-permission android:name="android.permission.CAMERA"/>
    <uses-feature android:name="android.hardware.camera"
        android:required="false"/>
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

The Scanner Function is below

Future <void> scanqr() async {
      final qrCode = await scanner.scan();
        setState(() {
          this.qrCode = qrCode;

//use permission_handler package and use the below code.. it will work fine

Future <void> scanqr() async {
          await Permission.camera.request();
          final qrCode = await scanner.scan();
            setState(() {
              this.qrCode = qrCode;
                Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
– Community
                Jan 19, 2022 at 10:31
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.