Open RaajeevChandran opened 1 year ago
Thanks for submitting your PR!
How can we see the behaviour difference?
I tried with the subroute_camera.dart
example in the example project and don't see any difference on Android.
@apalala-dev You're right. The example code in the subroute_camera.dart
works as intended because the pages are being replaced with Navigator.pushReplacementNamed
. But if you try using Navigator.pushNamed
to push the pages, the camera continues to run in the background. The same behavior could be seen when using other navigation packages like go_router
and auto_router
.
Here is a preview of the example code in subroute_camera.dart
when Navigator.pushNamed
is used,
https://github.com/Apparence-io/CamerAwesome/assets/61781996/ff3e5437-02e9-42db-8171-f1f209e1fbf8
A preview from this PR
The camera is disposed when a new page is pushed and re-initialized when popping back to the camera page
https://github.com/Apparence-io/CamerAwesome/assets/61781996/0c02853b-fa1c-4046-a2d2-9872a284d1b5
I just tried it and you're right, it disposes correctly the camera.
However, it also implies that when you get the focus back, the camera configuration is reset. E.g.:
I am not sure how it could be solved without adding a lot of complexity. I believe it would need:
Each time we would want to add an option, this logic would have to be respected (which might not be easy for a new contributor).
An other point to consider is that the package focus_detector
seem to not be maintained anymore and other forks have been published to pub.dev.
While I agree with your interpretation, I see this bug/issue as a foundational pre-requisite to anyone incorporating this package in their project. Presuming that Navigator.pushNamed
has more likelihood of usage than Navigator.pushReplacementNamed
, the camera continuing to run in the background is an obvious red flag.
Hello folks. Is there any news on manual dispose() method ? I don't use Navigator.pushReplacementNamed at all and I'd like to navigate between different modules in my app manually disposing Cameraawesome.
Description
Possible fix for #86
This pull request contains changes that disposes the camera when navigated to a new page and re-initialize the camera when popped back to the camera page.
Checklist
Before creating any Pull Request, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
).flutter analyze
without any issues.Breaking Change
If your feature break something, please detail it