What would be a bad use of streams?

Issue

Is there anything you should not do in Flutter with streams? Like for example is there any maximum number of streams that you should use or listen to?
Or is it better to use multiple StreamBuilder or just do a setState everytime you update a value?

Solution

Streams are a powerful feature in Dart. For example, many state management architectures use streams as a foundation to handle events and states. Almost every feature of your app can use streams for implementation.

You want to make sure you clean up any streams you are no longer using to prevent memory leaks.

StreamBuilder is a great widget and takes care of the cleanup. See this Flutter: Streambuilder – Closing of streams.

Answered By – Bret Hagen

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *