amugofjava / anytime_podcast_player

Simple, easy to use Podcast player app written in Flutter and Dart.
BSD 3-Clause "New" or "Revised" License
377 stars 99 forks source link

Lifecycle observer at root level. #34

Closed roeierez closed 2 years ago

roeierez commented 3 years ago

This PR moves the binding observer to a higher level. This is needed when embedding AnytimeHomePage as part of another app. At this case the lifecycle should be handled by the app itself which avoids removal of the observer when the AnytimeHomePage is disposed. In addition I have noticed that a lookup to a provider within the dispose method triggers exception so I moved the AudioBloc to its own state variable.

amugofjava commented 3 years ago

Hi @roeierez,

Unfortunetly this change breaks Anytime when running standalone. The issue is that you are trying to access the audio BLoC from initState() before they have been created in build. This results in:

======== Exception caught by widgets library =======================================================
The following ProviderNotFoundException was thrown attaching to the render tree:
Error: Could not find the correct Provider<AudioBloc> above this AnytimePodcastApp Widget

I think all the state will need lifting up. I have been meaning to refactor some of the Provider setup so I'll look into it.