fluttercommunity / get_it

Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur
https://pub.dev/packages/get_it
MIT License
1.36k stars 149 forks source link

Register Multiple Singletons At Once #294

Closed 1AhmedYasser closed 2 years ago

1AhmedYasser commented 2 years ago

When I setup up my singletons I do them as follows

GetIt locator = GetIt.instance;
locator.registerSingleton(Service1());
locator.registerSingleton(Service2());
locator.registerSingleton(Service3());
locator.registerSingleton(Service4());
locator.registerSingleton(Service5());

As the services grows in the app, registering them like this will become an overhead Is there a way to register all of them at once ?

sunderee commented 2 years ago

You can use a code generation package like injectable. It will auto-generate registrations of your singletons/factories + it has some advanced use cases.

1AhmedYasser commented 2 years ago

Thank you so much