kiatuki / animated_qr_code_scanner

QR Code Scanner for Flutter with animated targetting box
BSD 2-Clause "Simplified" License
80 stars 28 forks source link

QR goes black when animated in Android #5

Closed ctkqiang closed 4 years ago

ctkqiang commented 4 years ago

My Qr show Black after I zoomed In. What can possibly went wrong ? As My following code :

Library I used: animated_qr_code_scanner: {i used the latest 0.1.7}

bool _topContainerHasFocus = true;
...
...
  void _switchFocus() {
    if (_topContainerHasFocus) {
      _topContainerHeight = _shrunkenHeight;
      _bottomContainerHeight = _focusedHeight;
      _topContainerHasFocus = false;
    } else {
      _topContainerHeight = _focusedHeight;
      _bottomContainerHeight = _shrunkenHeight;
      _topContainerHasFocus = true;
    }
  }
...

...
  AnimatedQRView scannerFunctionality() {
    return AnimatedQRView(
      squareBorderColor: Colors.blue,
      animationDuration: const Duration(
        milliseconds: 40,
      ),
      onScanBeforeAnimation: (String str) {
        debugPrint(str);
      },
      onScan: (String something) {
        debugPrint(something);
      },
      controller: controller,
    );
  }

  AnimatedContainer qrScanner() {
    return AnimatedContainer(
      duration: const Duration(milliseconds: 60),
      curve: Curves.bounceIn,
      child: GestureDetector(
        onTap: () {
          setState(() {
            _switchFocus();
            resumeScanner();
          });
        },
        child: Container(
          width: _bottomContainerHeight * 0.75,
          height: _bottomContainerHeight * 0.75,
          decoration: BoxDecoration(
            borderRadius: const BorderRadius.all(Radius.circular(12)),
            color: Colors.white,
          ),
          child: Expanded(
            flex: 5,
            child: scannerFunctionality(),
          ),
        ),
      ),
    );
  }

and I got error like

I/Camera  (19607): handleMessage: 16
D/BufferQueueProducer(19607): [SurfaceTexture-0-19607-0](this:0x7b0559a800,id:0,api:1,p:577,c:19607) cancelBuffer: slot 0
I/BufferQueueProducer(19607): [SurfaceTexture-0-19607-1](this:0x7af2c36000,id:1,api:4,p:654,c:19607) queueBuffer: slot 2 is dropped, 
ctkqiang commented 4 years ago

I solved it with

void reRegisterCamerOverlay() {
    controller.flipCamera();
    controller.flipCamera();
  }

which in implement into the setState(); and it worked!