barras icon indicating copy to clipboard operation
barras copied to clipboard

Adds a callback when the code is scanned

Open aveit opened this issue 3 years ago • 3 comments

This PR adds the feature to call a custom callback when the code is scanned. Also, with this, we can now implement a more custom UI, for do that we won't use the default method Barras.scan, and instead we create the widget we want and put the BarcodeReaderPage, e.g.:

void openQRCodeReader() {
  Navigator.of(context).push(
    MaterialPageRoute(
      builder: (context) {
        return Scaffold(
          body: Stack(
            children: [
              BarcodeReaderPage(
                successBeep: false,
                borderColor: Colors.transparent,
                onScanned: (data) {
                  // HERE YOU ADD YOUR CUSTOM CALLBACK
                  // DON'T FORGET THAT YOU WILL HAVE TO MANAGE YOURSELF THE NAVIGATION PART
                },
              ),
              Column(
                children: [
                  IconButton(
                    icon: Icon(Icons.close_rounded),
                    color: const Color(0xFF212121),
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  ),
                  Center(
                    child: Text(
                      'Escaneie o QR code',
                      style: TextStyle(
                        fontSize: 30,
                        color: Colors.white,
                      ),
                    ),
                  ),
                ],
              ),
            ],
          ),
        );
      },
    ),
  );
}

aveit avatar Mar 30 '21 14:03 aveit

Alguma previsão de rolar esse merge? Ajudaria bastante...hehehe

apocalipse9 avatar Sep 21 '21 12:09 apocalipse9

@deadblit

aveit avatar Sep 21 '21 19:09 aveit

Alguma previsão de rolar esse merge? Ajudaria bastante...hehehe

Sim, em breve. Tem como você por favor atualizar o PR? Acho que deve ter quebrado por causa da implementação de null safety.

deadblit avatar Apr 20 '22 04:04 deadblit