state_notifier
state_notifier copied to clipboard
Add StateNotifierListener for create common widgets with no boilerplate code, no matter if provider or riverpod is used
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 StateNotifiers
s.
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.