khoren93 / flutter_zxing

Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
https://pub.dev/packages/flutter_zxing
MIT License
92 stars 52 forks source link

Questions about the package #37

Closed bounty1342 closed 1 year ago

bounty1342 commented 1 year ago

Hi,

Thanks you for the package, really like it.

I do have some questions and remarks.

1 - I wonder if the await is necessary there, at least it should be after the availableCameras().

  Future<void> initStateAsync() async {
    // Spawn a new isolate
    await startCameraProcessing();

    availableCameras().then((List<CameraDescription> cameras) {
      setState(() {
        this.cameras = cameras;
        if (cameras.isNotEmpty) {
          onNewCameraSelected(cameras.first);
        }
      });
    });
  }

2 - rebuildOnMount, probably clean to go with a widgetsbinding.instance.addpostframecallback 3 - Maybe on evolution could be to screenShoot the QRCode and display it. It should be doable with the takePicture method. 4 - Would you like me to add a scanning animation to the ReaderWidget, activated by a boolean, or better as an optional overlay so people could implement their own if they prefer ?

Regards

khoren93 commented 1 year ago

Hi @bounty1342!

Thank you for your interest.

  1. In my opinion, await isn't needed here, because the 'then' block will only be called when 'availableCameras()' is executed.
  2. If you can fix it and open a pull request, I will be very grateful.
  3. Yes, in the future I will add a separate widget for this feature, I think it will be especially useful for scanning multiple barcodes.
  4. You can set your custom layer using the scannerOverlay parameter. It's available right now.