Reputation: 1456
Until now I used Singleton pattern in my code, but I'm switching to Remi Rousselet’s Provider. And I have a business logic class that depends on 7 others as for now. ProxyProvider allows to use up to 6. How do I implement Provider pattern in this case?
class BlocAuth {
BlocAuth(this.serviceChatFirestore);
ServiceChatFirestore serviceChatFirestore;
var _state = AuthState();
var blocUser = BlocUser();
var user = UserModel();
var blocRouting = BlocRouting();
var blocBrands = BlocBrands();
var blocNotifications = BlocNotifications();
}
Upvotes: 2
Views: 765
Reputation: 277597
ProxyProvider isn't actually fixed to any number of dependency.
ProxyProvider vs ProxyProvider6 is just some syntax sugar. The latter isn't actually needed
For example:
ProxyProvider3<A, B, C, Result>(
builder: (_, a, b, c, previous) {
...
}
)
is strictly equivalent to:
ProxyProvider<A, Result>(
builder: (context, a, previous) {
final b = Provider.of<B>(context);
final c = Provider.of<C>(context);
...
},
)
So you can just do:
ProxyProvider6<A, B, C, D, E, F, Result>(
builder: (context, a, b, c, d, e, f previous) {
final g = Provider.of<G>(context);
...
}
)
Upvotes: 6