Multiple ProviderListeners in riverpod

Viewed 465

I have two StateNotifierProviders and want to listen to these two state changes in one widget. One method I can think of is to nest two ProviderListeners. But it'd be nice to have a solution similar to MultiBlocListener in Bloc package.

1 Answers

I am waiting for this feature. So, I am currently using this way. It's working for me.

ProviderListener(
                        provider: authNotifierProvider,
                        onChange: (context, state) {
                        },
                        child: ProviderListener(
                          provider: tenantCatLogNotifierProvider,
                          onChange: (BuildContext context, value) {
                           
                          },
                          child: Consumer(builder: (context, watch, child) {
                            final state = watch(tenantCatLogNotifierProvider);
                            final authState = watch(authNotifierProvider);
                            return IgnorePointer(
                                ignoring: state is TenantCatLogLoading ||  authState is AuthLoading,
                                child:);
                          }),
                        )
                      ),
Related