It is useful to have a widget that is similar to bloc's BlocListener , to avoid boilerplate and dependencies on provider or riverpod.
Usually you use listen or watch or Consumer respectively from riverpod or provider.
But in some projects of my work we use provider and in others we are using riverpod, but we have some common StateNotifierss.
So in order to share widgets between projects regardless of whether we use provider or riverpod, we use a StateNotifierBuilder instead of watch or Consumer, but some widgets has some listeners with predefined behaviors, so we use a widget similar to this , that is a StateNotifierListener
Having the StateNotifierListener widget as part of flutter_state_notifier would be ideal, so you avoid having to create it yourself or use external packages.
It is useful to have a widget that is similar to bloc's BlocListener , to avoid boilerplate and dependencies on
provider
orriverpod
.Usually you use
listen
orwatch
orConsumer
respectively fromriverpod
orprovider
.But in some projects of my work we use
provider
and in others we are usingriverpod
, but we have some commonStateNotifiers
s.So in order to share widgets between projects regardless of whether we use
provider
orriverpod
, we use aStateNotifierBuilder
instead ofwatch
orConsumer
, but some widgets has some listeners with predefined behaviors, so we use a widget similar to this , that is aStateNotifierListener
Having the
StateNotifierListener
widget as part offlutter_state_notifier
would be ideal, so you avoid having to create it yourself or use external packages.