Pause Stream when app enters background #393
Unanswered
daniel-stoneuk
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm fairly new to Flutter and Riverpod though I am experienced in Android, so please forgive any gaps in my understanding.
I figured this question is not strictly related to Riverpod, however, since I am using snapshot streams from Firebase with StreamProvider, here felt like the best place to ask.
How do people go about pausing a subscription to Firebase (or any other stream) whilst an app is closed. Here's some context:
Providing my stream is flutterfire, mapped to a list of objects like so
I've setup an autoDispose StreamProvider using this stream, and added some logging to help diagnose the lifecycle.
Running an app with
watch(dropStreamProvider)
works great, however, when the app is put in the background the stream is still being observed.I feel like a well built application should stop listening for updates once in the background to save resources, but there doesn't seem to be an easy way of implementing this with Riverpod.
I'd love to hear other people's opinions on this.
Beta Was this translation helpful? Give feedback.
All reactions