I'm in the process of building an app which uses streambuilder heavily for getting realtime data from firestore across multiple pages in the app.
As there is no stream close / stream subscription cancellation methods, is it safe to assume that streambuilder will auto detach listening to Firestore document changes when the widget is disposed by framework? Are there any caveats to be aware of.
Thanks.
A StreamBuilder closes its associated stream automatically when the widget subscribing to the stream is permanently removed from the widget tree:
https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/async.dart#L131
Or a permanent example if the link the master branch won't work one day:
https://github.com/flutter/flutter/blob/2ece1c3a174c3dd7099736f13b4ad16bb9b70c1d/packages/flutter/lib/src/widgets/async.dart#L131
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With