Search code examples
flutterqr-code

how to pop up text field value after scanning qr code generated by flutter


I have been looking to how to get generate qr codes and how to open a text field after scanning a code but I have not been able to find anything. I was looking at this package to get the qr code https://pub.dev/packages/qr_flutter and when i scan it I do get the qrdata but what I want is that after I scan the code a pop up appears with a text field where I can input a value and that value can be then used inside the code. Is that possible? If it is, can someone please direct me to what I need to use

I tried the qr_flutter package and while the qr code is being generated I am unable to figure out how to send data from mobile to the qr code.

class qrCode extends StatefulWidget {
  const qrCode({Key? key}) : super(key: key);

  @override
  State<qrCode> createState() => _qrCodeState();
}

class _qrCodeState extends State<qrCode> {
  final qrKey = GlobalKey();
  String qrData = 'Our Qr Data';
  @override
  Widget build(BuildContext context) {
    return Container(

      child: RepaintBoundary(
        key: qrKey,
        child: QrImage(
          data: '1', //This is the part we give data to our QR
          //  embeddedImage: , You can add your custom image to the center of your QR
           semanticsLabel: 'hello',
          size: 250,
          backgroundColor: Colors.white,
          version: QrVersions.auto,
          //You can also give other versions
        ),
      ),
    );
  }
}

Solution

  • I used scan package which has a onCapture function to let you perform your tasks upon capture. You can just

    onCapture:(){
    // show your pop up which contains textfield
    }