Search code examples
flutterzxing

barcode_scan Flutter plugin to only scan QR code (not to accept 2d barcode)


Scanning works fine for QR and 2d barcode. Is there other way to exclude 2d barcode for the barcode_scan Flutter plugin?

I tried the qrcode_reader plugin but it is deprecated and there is no overlay in the camera.


Solution

  • I use qr_mobile_vision. It is insanely fast and very accurate from my usage trials.

    An object defined using this library can be placed in your widget tree.

    Once you master the library then based upon my understanding of what you desire. overlay, etc. I recommend you roll your own overlay using something like this pseudo code (not tested):

    bool xHairOn=false;
    
    Stack ( children : <Widget> [
      SizedBox (
        width: 300.0,
        height: 300.0,
        child: new QrCamera(
          qrCodeCallback: (code) {
            setState(() {
              // que changes to your overlay visuals here
              xHairOn=true;
              });
    
            // wait 1/2 second
            new Timer(const Duration(milliseconds: 500), () {
              setState(() {
                  // que crosshair to disappear after 1/2 second has expired
                  xHairOn=false;
                  });
               });
          ),
        )
      , xHairOn == true ? Image.asset("assets/image/crosshairs.png", width: 300 , height: 300 ) 
                        : Container ( width: 300, height : 300 )
      ])
    

    Note in the above I am doing this from memory, thus the Image.asset may need to be placed in the stack prior to the SizedBox Widget