freedelity / flutter_native_barcode_scanner

Fast barcode/QR scanner flutter plugin using PlatformView and processing on native side
https://pub.dev/packages/native_barcode_scanner
BSD 3-Clause "New" or "Revised" License
6 stars 8 forks source link

Fix android camera already in use error #18

Closed danleecomp closed 8 months ago

danleecomp commented 8 months ago

Hello! I'm Dan Lee, a lead developer from South Korea.

While using your library, I encountered an error in the Android environment stating that the camera was already in use when trying to load the camera preview on a different screen. This issue was not present in the iOS environment.

Upon investigation, I discovered that even after cancelling the event subscription with cancel(), the camera remained open at the native level, preventing its use on other screens.

To resolve this error, I added a method to manually unbind the camera in the Android environment within the library source code and called it during dispose(). Other way, Adding this into cancel() method might be good also.

Thank you for developing such an excellent library.

Verbruik commented 8 months ago

Hi @Danik420 !

Thanks for the PR, it looks good to me, I will test it later and it should be merged if everything is alright !