AmolGangadhare / flutter_barcode_scanner

Barcode scanner plugin for flutter. Supports barcode scanning for Android and iOS
https://pub.dev/packages/flutter_barcode_scanner
MIT License
380 stars 499 forks source link

How To close the stream on getting fixed number of scans in continues scan #113

Closed nicks258 closed 3 years ago

nicks258 commented 4 years ago

Hi Thanks for the plugin. I am using continues scan stream for doing multiple scans but i want to stop scanner after 3-4 scans. can you please suggest how to do this Thanks

    FlutterBarcodeScanner.getBarcodeStreamReceiver("#ff6666", "Cancel", false, ScanMode.DEFAULT)
        .listen((barcode) {
          print(barcode);
          if(barcode.toString().length!=0){
            for(final i in list){
              if(list[i]["awb"] == barcode.toString()){
                print("Hello 0>>>>>");

              }
            }
          }
      /// barcode to be used
    },onDone:()=>{ print("onDone")},onError: ()=>{ print("onERROR")});
nicolasvahidzein commented 4 years ago

i second this, i can't seem to implement this

AmolGangadhare commented 3 years ago

The continuous scan will scan the barcode until the user press cancel. You need to make changes to the native part to achieve this requirement.

You can always fork the repo and play around.

Closing this issue for now, feel free to open a new issue if any problem faced in the plugin.

SYThomasNordmeyer commented 2 years ago

Pitty you just closed this issue, adding the feature would increase the value of your nice component. Having the same problem and find this is quiet common. When scanning for a valid barcode quiet often invalid ones come along. In this case you scan as long as you find a valid one or user cancels. Did not find a way to handle the first case.

SYThomasNordmeyer commented 2 years ago

Hi @AmolGangadhare, I just saw there is already an implementation in the pipeline. If you merge PR https://github.com/AmolGangadhare/flutter_barcode_scanner/pull/246 the solution will be in place, I guess.