juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
744 stars 444 forks source link

I need to use the scanner in two places... #1002

Open julianiaccopucci opened 1 month ago

julianiaccopucci commented 1 month ago

but when I use different instances on each view, it seems like there are some resources that are shared so I need to properly handle the start/stop and disposal of resources. I get "start() already called" (even I stop it on the other view) and other problems (stops scanning).

This is my setup: A bottom bar with three buttons, opening three views.

Left bottom bar button: a view with a button. Pressing the button it pushes the scanner. Then the user can press 'back' back to the view, disposing the scanner. Middle bottom bar button: shows the scanner, which the user can use right away. (it never disposes as it's in the bottom bar)

How do I manage the resources just so I can have the set up I mentioned? One instance will never dispose, and the other will come in and out.