juliuscanute / qr_code_scanner

QR Code Scanner for Flutter
BSD 2-Clause "Simplified" License
999 stars 759 forks source link

Open camera not working #550

Open KuntheasSoung opened 2 years ago

KuntheasSoung commented 2 years ago

photo_2022-06-02_23-29-11

Camera not working after I upgrade my flutter to 3.0.1 and dart 2.17.1.

PhRezende-eng commented 2 years ago

Some update?

micaelsn commented 2 years ago

Same problem here

nguyenthao1988 commented 2 years ago

Same problem first open camera not start

xang555 commented 2 years ago

same issue!

I temporary fixed by call controller.resumeCamera(); in _onQRViewCreated callback function

  void _onQRViewCreated(QRViewController controller) {
    setState(() {
      this.controller = controller;
    });

     // call resumeCamera fucntion
    controller.resumeCamera();

    controller.scannedDataStream.listen((scanData) {
      setState(() {
        result = scanData;
      });
    });
  }
zakblacki commented 2 years ago

Actually if you switch camera to front then back again it will work this only happen on camera launch

swenhancer commented 2 years ago

None of the workarounds works for me. Samsung S10+

ricardo-kowalski commented 2 years ago

None of the workarounds works for me. Samsung S10+

Same for me :/

dnadawa commented 2 years ago

Same for me

ayechan-maung commented 2 years ago

same issue!

I temporary fixed by call controller.resumeCamera(); in _onQRViewCreated callback function

  void _onQRViewCreated(QRViewController controller) {
    setState(() {
      this.controller = controller;
    });

     // call resumeCamera fucntion
    controller.resumeCamera();

    controller.scannedDataStream.listen((scanData) {
      setState(() {
        result = scanData;
      });
    });
  }

When I put the code there, the app going to crash.

hmhung2531991 commented 2 years ago

same issue!

I temporary fixed by call controller.resumeCamera(); in _onQRViewCreated callback function

  void _onQRViewCreated(QRViewController controller) {
    setState(() {
      this.controller = controller;
    });

     // call resumeCamera fucntion
    controller.resumeCamera();

    controller.scannedDataStream.listen((scanData) {
      setState(() {
        result = scanData;
      });
    });
  }

Work for me

swenhancer commented 2 years ago

@hmhung2531991 which platform and which device?

hmhung2531991 commented 2 years ago

I tested on Android. This issue happened on Android also

svprdga commented 2 years ago

I can confirm the issue and the workaround proposed by @xang555 works, though it provokes an error when running in iOS, this is what is working for me in both Android & iOS:

QRView(
  key: cameraKey,
  onQRViewCreated: (QRViewController controller) async {

    // [...]

    if (Platform.isAndroid) {
      await _qrViewController?.resumeCamera();
    }

    // [...]
  }
)
edopras commented 2 years ago

I can confirm the issue and the workaround proposed by @xang555 works, though it provokes an error when running in iOS, this is what is working for me in both Android & iOS:

QRView(
  key: cameraKey,
  onQRViewCreated: (QRViewController controller) async {

    // [...]

    if (Platform.isAndroid) {
      await _qrViewController?.resumeCamera();
    }

    // [...]
  }
)

work for me. Thanks

roiskhoiron commented 2 years ago

same issue!

I temporary fixed by call controller.resumeCamera(); in _onQRViewCreated callback function

  void _onQRViewCreated(QRViewController controller) {
    setState(() {
      this.controller = controller;
    });

     // call resumeCamera fucntion
    controller.resumeCamera();

    controller.scannedDataStream.listen((scanData) {
      setState(() {
        result = scanData;
      });
    });
  }

thanks it's work for me.