How to open barcode scanner in a custom widget?

Issue

I want to open barcode scanner in a container – Custom Widget (Not just barcode scanner QR). For example, while scanning the barcode at the top of the screen, I want to put a button at the bottom to add the barcode I scanned to the shopping cart. Can you suggest a library or method to do this?

I am putting an example picture below.

enter image description here

Solution

Use Stack widget to achieve this (to overlap one widget on another).
I used qr_code_scanner plugin in my case.

Stack(
    children:[
        /* replace this widget with your own */
        QRView(
            key: qrKey,
            onQRViewCreated: _onQRViewCreated,
        ),
        Column(
            children:[
                /* button control here */
            ]
        ),
    ]
);

See https://api.flutter.dev/flutter/widgets/Stack-class.html for more info about stack.

Answered By – Pathik Patel

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *