shaxxx / flutter_barcode_listener

Flutter widget to listen for scanned barcode via hardware scanners
MIT License
45 stars 46 forks source link

Android: Scanner return nothing in any moment #30

Closed navarrete0 closed 1 year ago

navarrete0 commented 1 year ago

Code:

    BarcodeKeyboardListener(
    bufferDuration: const Duration(milliseconds: 200),
    onBarcodeScanned: (barcode) {
    if (kDebugMode) {print(barcode);}
      if(barcode.isNotEmpty) {
        searchBarcode(barcode);
      } else{
//restart listener??
        Get.snackbar(
            "Not found",
            "Please restart app",
            icon: const Icon(Icons.error, color: Colors.black),
            snackPosition: SnackPosition.BOTTOM,
            duration: const Duration(seconds: 2)
        );
      }
    }, child: const SizedBox(
    width: double.infinity,
    height: 1),),

How can I restart the listener into the app if i get empty?

shaxxx commented 1 year ago

There is no need to restart anything. BarcodeKeyboardListener will be listening if it's in the widget tree.