-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to control audio service from multiple consecutive pages #227
Comments
Hi @Rohitrajp The problem appears to be that you are pushing the second page onto the stack, while the home page isn't completely removed from the stack, and isn't disposed. So you haven't disconnected from the home page before connecting in the second page. There are two ways to approach this. One way which is described in the wiki tutorial is to push the connection logic up to a higher point in the widget tree that is shared across all screens. An alternative would be to make each screen implement |
Hi @ryanheise First of all, apologies for this huge delay in response. Thank you for the above mentioned alternatives. I have tried out both Thank you for taking your time to advise on this issue I was facing, it's a real life saver. |
Great. I've now officially added the |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service. |
Bug Description
My application is a media player and that requires me to be able to control the audio service from multiple consecutive pages.
However, there are two kinds of errors based on the type of page navigation used:
Push/PushNamed navigation
When a new page with
audio_service
controls is pushed over another page withaudio_service
controls, theaudio_service
is controllable from the pushed page, but once the pushed page is popped, the initial page is not able to control the service properly. (all audio_service controls will be pending till a hot restart)PushReplacement/PushReplacementNamed navigation
When a new page with
audio_service
controls is pushed with replacement over another page with audio_service controls, the following error is raised:Disclaimer
I have implemented
WidgetsBindingObserver
andWillPopScope
as done in your example in both pages.Minimal reproduction project
I have modified the example application to better showcase this bug. Please clone my fork and run the example app.
https://github.com/RohitRajP/audio_service.git
To Reproduce
Steps to reproduce the behavior:
audio_service
audio_service
connection.audio_service
in the app will become non responsive or raise the errors shown.Expected behavior
The
audio_service
must be controllable from any page in the same application.Runtime Environment (please complete the following information if relevant):
Flutter SDK version
*** Additional Information***
This bug is not present, when we navigate to a page that does not contain
audio_service
connection before navigating to the destination page containing theaudio_service
controls.The text was updated successfully, but these errors were encountered: