Many SO questions explains that
Streambuilder
manages its stream by itself and unsubscribe to the stream in its onDispose method. https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/async.dart#L131
Is streamBuilder Widget needs to be disposed?
Other Flutter Github questions explains that
dispose or deactivate
methods are not called when navigating to the next screen. https://github.com/flutter/flutter/issues/50147#issuecomment-1033773923
So How to make Streambuilder from 1st screen unsubscribe when navigating to a 2nd screen?
With :
- a 1st screen with streambuilder using a stream from a function calling Firestore snapshots
- a 2nd screen having also a streambuilder using a stream from same function (calling Firestore snaphots but with different parameters)
When calling the Firestore stream on 2nd screen, i have noticed that the stream results get duplicated due to the streambuilder of 1st screen still listening to stream.