Closed Alekcei closed 5 years ago
@Alekcei I am not sure what you mean? You can already do this
Injector.getInjector("injectorInstanceName").get<SomeType>();
or to get the default instance of the injector
Injector.getInjector().get<SomeType>();
I want get defult instance by short chain
Injector.get<SomeType>();
@Alekcei I don't think this adds anything to the library and in a way would start to promote a bad practice. The injector "getInstance" method was implemented on purpose as you can have multiple instances of injectors. I think the default use case would be to only use your injector in a container during application startup to configure all the services. Thereafter, everything is injected so you shouldn't need to access the injector.
Nonetheless why not just do this?
final injector = Injector.getInjector();
injector.get<SomeType>()
i setting service in my widget, the following way.
final httpService = Injector.getInjector().get<HttpService>();
final carService = Injector.getInjector().get<CarService>();
I wanted have short chain for this.
Whether it is possible to add a binding by annotations
@Injection
final HttpService httpService;
Sorry @Injection notation would rely on mirrors which is not available in Flutter.
Please add static Inection.get(SometType)