The birth of BlocConsumer
is actually to reduce the tedious code, which is worth it.
But the birth of BlocConsumer
will also confuse some people. If we just give users the concept of BlocConsumer
, I think it will better understand bloc.
example:
BlocConsumer(
// Only use child or builder
child: someWidget,
// builder: (context, state, child) { ... },
listener: (context, state) { ... },
)
I think this way, bloc will be simpler and more flexible.
Want to know what feedback about this.
I would prefer Consumer and Listener each having one single purpose. It's clearer that way.
I don't think including a double meaning for a widget makes it simpler.
BlocConsumer
can do BlocBuilder
, so, why do we need BlocBuilder
? Is it better to use BlocConsumer
instead of BlocBuilder
.
Let us think about the relationship between BlocConsumer
and BlocBuilder
, BlocListener
,
BlocConsumer
is a BlocBuilder that adds a listener, and also a BlocListener
that adds a builder. BlocConsumer
is like a fusion of the two, but is it different?
Perhaps it is a good choice to keep only BlocConsumer
and BlocListener
?
Builder
is more idiomatic to Flutter, which has a dozen of Builder
classes and only a couple of Consumer
s. Which seems only logical considering that every widget has a build
method.BlocConsumer
was introduced to reduce the boilerplate of nesting BlocListener
and BlocBuilder
, which are very basic, common and easy to understand concepts. So how it is expected to facilitate understanding by removing this foundation in favor of the compound class with the more complex constructor and the mutually exclusive attributes?BlocProvider
to be removed in favor of the MultiBlocProvider
which was introduced for the similar design reasons.I completely agree with @jibiel. Closing this for now but if anyone has a strong argument in favor of removing BlocBuilder and BlocListener feel free to leave a comment and I鈥檓 happy to reopen the issue 馃憤
Most helpful comment
Builder
is more idiomatic to Flutter, which has a dozen ofBuilder
classes and only a couple ofConsumer
s. Which seems only logical considering that every widget has abuild
method.BlocConsumer
was introduced to reduce the boilerplate of nestingBlocListener
andBlocBuilder
, which are very basic, common and easy to understand concepts. So how it is expected to facilitate understanding by removing this foundation in favor of the compound class with the more complex constructor and the mutually exclusive attributes?BlocProvider
to be removed in favor of theMultiBlocProvider
which was introduced for the similar design reasons.