Flutter BLoC: Is using nested StreamBuilders a bad practice. You cannot do otherwise using widgets. That’s one of the limitations of the widget system: things tend to get pretty nested
There’s one solution though: Hooks, a new feature coming from React, ported to Flutter through flutter_hooks (I’m the maintainer).
The end result becomes this:
final snapshot1 = useStream(firstBloc.stream1);
final snapshot2 = useStream(secondBloc.stream2);
return CustomWidget(snapshot1.data, snapshot2.data);
This behaves exactly like two nested StreamBuilder, but everything is done within the same without and without nesting.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.