I think I have now at least a vague idea of how to use a BLoC, Stream Builder and Inherited Widget(or Model) in my app (nothing special, but for me it took time), but playing with the Scoped Model
I had a sort of existential crisis: I feel they can mostly do the same thing or at least I can achieve the same apparent results with any of them, but I don't have the competence to understand when and why one is better than another.
Scoped Models vs Bloc
In short: If you have small apps use scoped models since bloc tends to complicate it, and if you have big app use bloc.
See this article for detailed explanation: bloc vs scoped_model
Stream Builder vs Inherited Widget
Here is a nice comparison between stream builder and inherited widget given by Remi Rousselet: https://mcmap.net/q/668518/-why-use-inheritedwidget-while-we-can-use-broadcast-streams-streambuilder-and-static-variables-closed
Streams/Sink definitely are excellent to store a state. There are some existing architectures, such as BLoC which uses them a lot.
But, Streams don't entirely replace InheritedWidget
either. InheritedWidget
comes with the cool ability to override it's content for only a part of the screen. One cool application of this is Theme
.
Generally speaking, Streams
are cool to store business logic. But when you need to store UI logic, InheritedWidgets
takes the upper hand.
business logic
and what is UI logic
? –
Belorussia © 2022 - 2024 — McMap. All rights reserved.
StreamBuilder
andInheritedModel
are more general purpose. BLoC, ScopedModel and Redux are more architecture specific. You can probably combine Redux with BLoC or ScopedModel, but as said, I didn't have a closer look at these 2 yet. – Golter