digit_scanner 1.0.3+1 copy "digit_scanner: ^1.0.3+1" to clipboard
digit_scanner: ^1.0.3+1 copied to clipboard

A Scanner package used for scanning QR Codes and GS1 Barcodes.

digit_scanner #

A Scanner package used for scanning QR Codes and GS1 Barcodes.

Scanner

Getting Started #

To use this package, add the following dependency to your pubspec.yaml file:

dependencies:
  digit_scanner: 0.0.0-dev.1

Initialize the DigitScannerBloc provider in your application

  BlocProvider(
                create: (_) {
                  return DigitScannerBloc(
                    const DigitScannerState(),
                  );
                },
              ),

To Clear the scanner state

context.read<DigitScannerBloc>().add(
    const DigitScannerEvent.handleScanner(),
);

Navigating to DigitScanner Page

 context.router.push(DigitScannerRoute(
                              quantity: 1, // Max no. of codes to be scanned
                              isGS1code: false, // Set Flag to true for scanning GS1 barcode
                              singleValue: true, // Set Flag to false for scanning mutiple codes
                            ));

Wrap the DigitScannerListener or DigitScannerBuilder in your widget tree wherever you need the Scanned codes.

BlocListener<DigitScannerBloc, DigitScannerState>(
                  listener: (context, scannerState) {
                   if (scannerState.qrCodes.isNotEmpty) {
                   //
                   }
                  },
                  child: BlocBuilder<DigitScannerBloc, DigitScannerState>(
                  builder: (context, scannerState) {
                  if(scannerState.qrCodes.isNotEmpty){
                   return Text(scannerState.qrCodes.last); ///Get the scanned codes after scanning from the scanner State
                   }
                   else {
                   return Container();}
                  }
                  ));