injectable icon indicating copy to clipboard operation
injectable copied to clipboard

What's the differences between Singleton and Injectable? Dependency Injection in Flutter - Type of declaration for the get_it/injectable package

Open alperefesahin opened this issue 1 year ago • 0 comments

I want to learn the differences between Singleton and Injectable declarations. I just know that the Singleton provides only one instance, and for the injectable, it provides a new instance when we use/call it, every time.

I tried to understand completely, but there are some things that I can not get it. I think I need one example for this.

I can give an example for it, and please share your knowledge and ideas with using the below example:

Example:

Let's assume we use firebase login with email and password. It does not matter what we use for state management. So, should it be singleton or injectable? I thought that we need to use injectable since for every login we need a new request for the service.

For the singleton (or lazySingleton) I can not give another example for this example, since I do not get it exactly. Please give me your knowledge to solve this problem. For what situation do we need lazysingleton or singleton?

Thanks

alperefesahin avatar Oct 11 '22 14:10 alperefesahin