Flutter: General confusion about dependency injection, service locator, get_it, provider and bloc

838 Views Asked by At

Assumptions(please check, I am probably stupid):

As far as I read, the Dependency Injection Pattern and the Service Locator Pattern, are both 2 ways to achieve Inversion of Control. The package 'get_it' facilitates the Service Locator and 'provider' the Dependency Injection. Bloc is enforcing the bloc pattern, which is a nice way to separate ui, logic and data. Bloc is using provider for Dependency injection.

Questions:

So, based on that, I don't understand why people use get_it in conjunction with bloc and/or provider. Isn't that just confusing because you are mixing patterns? There was a discussion about that with @Rémi Rousselet here: https://github.com/FilledStacks/flutter-tutorials/pull/2

Also, I can't seem to find a nice code example of a mvvm code architecture(or generally a nice separated code architecture), using provider only instead of bloc(I wanted to see if that is a nice alternative to bloc, maybe someone has a comment on that)

0

There are 0 best solutions below