Flutter TDD Clean Architecture Course [13] - Dependency Injection
Вставка
- Опубліковано 28 лип 2024
- 📗 Learn from the written tutorial 👇👇
resocoder.com/flutter-tdd-cle...
👨💻 Do you write good code? Find out now!
resocoder.com/good-code-quiz
We have all of the individual pieces of the app architecture in place. Before we can utilize them by building a UI though, we have to connect them together. Since every class is decoupled from its dependencies by accepting them through the constructor, we somehow have to pass them in.
We've been doing this all along in tests with the mocked classes. Now, however, comes the time to pass in real production classes using a service locator.
Go to my website for more information, code examples, and articles:
● resocoder.com
Follow me on social media:
● / resocoder
● / resocoder
● / resocoder
Can't wait for the next part. I am curious how they all connect to each other:) This is like a Netflix show:D
I dont know since which version, but now you can do sl.registerLazySingletonAsync(), this method allow you to instantiate async dependencies, so await async in init() is not longer necessary; you can implement shared prefs like this;
sl.registerLazySingletonAsync(
() => SharedPreferences.getInstance());
Oh... Man.. this playlist is 💎
Even after this years. 😩
Thanks sir..❤
I hope you're doing great 🥳
man i am glad somebody out there invented depedancy injection at some point. this thing is gold
Bro 😀, this is beautiful. I have followed your tutorials one by one. You have indeed prepared me for real app development. I am now building better, faster and more stable apps.
I really can't appreciate your effort enough. Thank you
Excellent reso, I had used Get It in some projects, but as always, you add that expertis that makes us go more there and do things in the best way, simply the best video tutorials.
Thank you for pushing continouesly, I can't even get enough free time to keep up the pace 😂 To many different things to do... To many ideas and hobbies.
Keep up the good work! 🔥
This series is so cool! I even made the whole thing in rust after my non clean approach collapsed pretty quickly
Awesome tutorial, thanks your effort.
Once again awesome!!!
Thank you very much ! Nice tutorials !
man you are the best. Thanks for sharing your knowledge
Thank you for the perfect content
Great content, thanks for sharing. Btw, docs mention that from v5.0 on you can pass a `dispose` function when registering any Singletons.
Awesome!!!!
Going to the last one!!! \o/
Great video!
Greaat job brother !
top-notch quality content
Hi Matej, thanks again for continuing this great series. I don't think there is anyone else taking on tricky topics like TDD! If we are using the Provider package to make services available to the UI, is 'Get It' still necessary? Aren't they providing the same functionality?
Great :D
how dare these 3 people disliked this.Thank you Reso
finally today i get all my answers about those abstract classes which we create but never pass anything
I think we need a video about how to use dependency injection without get_it, not all of the companies like to use external packages for all the implementation as needed
I ran into Unhandled Exception and added "WidgetsFlutterBinding.ensureInitialized();" in main method, before runApp() and it works
Thank you very much, I have a question and maybe someone can answer me: if the main () method is async, then the whole application will be async?
If I want to get data from another previous page how can I do it? If the bloc is a factory, it will return a new instance when I call it in getIt, so all the data is new and not from the previous screen, how can I do it?
what if I have multiple implementations of repository and I want to switch between them at runtime?
I hope you are already planning to add new feature in this project and link with the number trivia feature.
Thank you again for such great and quality content.
I'm not going to expand on this project further but there are certainly more tutorials coming!
@@ResoCoder i wish it will also based on TDD
We are supposed to get the last part of this tutorial today, don't we?
Gosto muito dos seus tutoriais...
Translation: I Like your tutorials so much.
I'm a simple man, I hear that, I like.
Any idea on how to register Hive DB?
Where do the GraphQL queries fit in the clean arch. does it belong to the data layer? or the domain layer? By using GraphQL I tell the backend what is needed for the application to render for example a screen, so the query details seem like business logic details. Abstracting it in the data layer would require to have queries for every use case scenario. This seems like shifting the domain details to the data layer. What is your take on this.
Amazing content. BUT
I have a mixed feeling about the code organization of this part. its maybe okay for this number trivia app, but for larger apps injection_container file will be too big and unmanageable. also it seems redundant to initiate all dependency of every feature/pages beforehand, even though that feature/page is not used yet.
PLEASE: is there a more concise way for dependency injection? maybe in separate files of each feature/page?
Thanks for the informative playlist.
Thanks a lot, reso for the grate greate content.
I have a question about how can you have something like scopes in Dagger. I have an application that will add an interceptor with access_token to the HTTP client. so if the user does log in the HTTP client should change and every dep that uses it.
I ended up creating a class named AuthManager extending ChangeNotifer that manages the user lifecycle in the application. and ApiClient class that I will inject a factory builder function that is used to build the HTTP client. ApiClient is subscribed to AuthManager changes whenever it changes ApiClient rebuild the HTTP instance using the factory builder function.
what is your opinion and what would you do differently?
@Essenc Thank you a lot for your comment. This is what I have ended up doing. pastebin.com/Q71E0mky . You approach is okay but the issue rises when the `UserInfo` that contains the logged-in user details is a dependency to other classes. I was looking for a way so if I change a dependency in the top of the dependency graph all it dependent children will rebuild. This was achievable in android using Dagger library using @scopes. This also can be solved if I use the Provider library but using ProxyProvider is so much boilerplate. what do you think ?
cool
can i get the whole source code of your Number trivia app? i am stuck between getIt function
Please make a tutorial for the new 'flutter_bloc' 1.0.0 version its so much different from your previous videos
It's on the way!
@@ResoCoder Thank you love your tutorials, keep it up ❤️
Any news?
It's not that different at all. Just two things that you have to change inside bloc_test file: 1. Use "bloc.add(myEvent)" insead of "bloc.dispatch(myEvent)"; 2. Instead of "expectLater(bloc.state, emitsInOrder(expected);" use "expectLater(bloc, emitsInOrder(expected));"... Hope this helps!
@@ResoCoder Any update on this? Thanks very much for such an awesome tutorial series.
alternative to get_it?
Kiwi or ProxyProvider.
@@ResoCoder thanks
dependency injections
How to add dependency Injection in this project
stackoverflow.com/questions/61084640/how-to-add-dependency-injection-in-flutter-with-provider
You provide great information that is essential for developers to know about. However, I wish the tutorials were a bit shorter, less repetition of not needed stuff (e.g. check my blog tutorial, or this sort of double intro). At times it seems like explanation could have been provided in a more concise manner. Some basic stuff should not been explained in my opinion here (e.g. details about what is DI - architecture is a bit of a level up so most likely people already know about it, they might just want to know implementation in flutter). Overall, great videos. I've learnt plenty from about about mobile development.