USE CASE 1:
Lets say I have a screen which displays 3 different lists, List-1, List-2, List-3 (display as horizontally scrollable lists).
The 3 lists are fetched from 3 different network requests. And I am using BLOC pattern to contain all network request inside and BLOC and then feed the result back to page using streams.
Now, which is better way to do this:
- Use Single StreamBuilder wrapping the whole state of page (all the 3 lists) and in Bloc load all 3 network request and send the updated State through stream.
- Use 3 StreamBuilders for 3 lists listening to 3 Streams in the BLOC. So as each network request completes only the corresponsing list Stream is triggered and built.
USE CASE 2:
A Login page with Components:
- User name and password textFields, where user name shows list of suggestions using Stack
- A submit button with support for CircularProgressIndicator within it.
Using 1 StreamBuilder to wrap whole state or Use 2 StreamBuilders for 1 wrapping textFields and 1 StreamBuilder wrapping submit button. So only Button will be rebuilt if Loading state changes.
Are there any tradeoffs or performance issues caused by having Multiple StreamBuilders in a single screen?
UPDATE: Added another use case.
I would use different streams. First of all, looking into the "official" bloc examples, you will find multiple blocs for a page, for example filtering vs list.
In your example, if you have 3 network requests, you may get 3 different answers at different times/speeds. So for UX, I would show what you get and not wait, until the last bit got transmitted