1

When I create a Stream object in Flutter (Dart), I got a warning message that I should close this Stream after used it. I wonder that have any problem when I create a new Stream but not close it. (Seem like memory leak)

I used memory tool for finding memory leak in that's case but fail. Why should I close the Stream. May I miss anything about stream in Dart?

P/s: In my application, I have to create many Stream object and share it with many widget. It's easy to code if I don't need to manage the Stream instance.

Trần Đức Tâm
  • 4,037
  • 3
  • 30
  • 58
  • I think Stream will automatically close when the widget permanently removed from the widget tree. Just close Stream when dispose is enough. It's mentioned here: https://stackoverflow.com/questions/55662255/flutter-streambuilder-closing-of-streams – hoangquyy Sep 08 '20 at 04:11
  • I wonder how about detach the subscribed widget from widget tree and move the stream into another one. – Trần Đức Tâm Sep 08 '20 at 05:19

0 Answers0