Reinstantiate classes created by Provider in Flutter

Viewed 39

I am building an app using Flutter + Package Provider with BLoC Pattern.

So i do something like this:

return MultiProvider(
      providers: [
        Provider<AuthenticationBloc>(
          create: (_) => AuthenticationBloc(AuthenticationService()),
          dispose: (_, authenticationBloc) => authenticationBloc?.dispose(),
        ),
      // others providers
      ],
      child: MaterialApp(

The thing is, when the user logout, i have to manually reset the blocs. Which can led to errors if i miss something. It does not seem like a good pattern/thing to do.

So my question is: Is there an easy way to reinstantiante the classes created by provider? Some elegant way in which all provided instances would be new/reseted?

0 Answers
Related