No video

Get_It package - Dependency Injection with Service Locator Pattern in Flutter & Dart

  Рет қаралды 44,115

Flutter Explained

Flutter Explained

Күн бұрын

You want to glue together your different layers in your application, then this package is for you. The Get_It package brings an easy to use Service Locator directly into your application. The Service Locator will make it super easy to connect your app and your different layers together.
If you want to see Max when he is Live Streaming, checkout kick.com/devcafe
#GetIt #Flutter #Dart
You like our work and would like to support us, feel free to join us on Patreon.
/ flutterexp
Get_it on pub.dev
pub.dev/packag...
State Management with Get_it?
pub.dev/packag...
** Social Medias **
Website: flutter-explai...
Say hi to Max
Twitter: / flutter_exp
GitHub Max: github.com/md-...
LinkedIn: / max-weber-9889a3ba
Say hi to Mahtab
Twitter Mahtab: / mahtab_dev
GitHub Mahtab: github.com/mt-...

Пікірлер: 77
@emmanuelolajubu4144
@emmanuelolajubu4144 4 ай бұрын
Even after 3years, i still find this video helpful
@michaelokhaimoh6809
@michaelokhaimoh6809 2 жыл бұрын
After searching the internet and reading medium articles to little satisfaction, this did justice to everything. Thank you very much. Subscribed!!
@FlutterExplained
@FlutterExplained 2 жыл бұрын
Glad it was helpful!
@juliusherbert709
@juliusherbert709 Жыл бұрын
I have commented probably 4 to 5 times on KZbin. And this is the 6 times. I just wanted to say thanks for the well-structured teaching approach! Awesome teacher. I'd like the to-do style used to walk me through the video and the justification of each step. Amazing flow!
@FlutterExplained
@FlutterExplained Жыл бұрын
Wow, thank you so much :) I am glad you liked it!
@ionolaru4086
@ionolaru4086 3 жыл бұрын
Dependency Injection Pattern left the chat
@ManontheOutside
@ManontheOutside Жыл бұрын
Thanks, this is a great explanation. I struggled to understand this until I found your video. Thanks so much!
@googleuser2355
@googleuser2355 3 жыл бұрын
I was too lazy to read the documentation 😂.. thanks you were there🥰
@awaishaleem6596
@awaishaleem6596 Ай бұрын
very brief and helpful.
@anasalbattiri003
@anasalbattiri003 Жыл бұрын
Thank you very much!
@FlutterExplained
@FlutterExplained Жыл бұрын
You're welcome!
@makemypetgamedevprocess6475
@makemypetgamedevprocess6475 3 жыл бұрын
Finally!!! I was now able to understand how to use it and what is it, thanks :)
@EnriqueLeyvaJose
@EnriqueLeyvaJose 3 ай бұрын
Thanks for the video Max, Could you do one please using GetIt in tests? Cheers from Sauerland
@ahmedadnan5875
@ahmedadnan5875 3 жыл бұрын
good example for how to use get_it in real project, thanks
@FlutterExplained
@FlutterExplained 3 жыл бұрын
You are most welcome :) I hope it helps you along the way!
@keyonlewis7574
@keyonlewis7574 4 ай бұрын
Thanks a lot
@ahmedamineguerraiche5672
@ahmedamineguerraiche5672 10 ай бұрын
thank you very much
@yonathanhailemelekot5238
@yonathanhailemelekot5238 Жыл бұрын
you make it super easy. and that is not fair🤣
@christianmarpert3844
@christianmarpert3844 2 жыл бұрын
I really like the idea of a service locator, especially that it is flutter independent as I understand. In other words, I don't need to pass something around the widgets like with provider. I would be interested, if this works well with the bloc pattern. instead of flutter_bloc, which uses provider under the hood for DI, couldn't I use get_it? Would be great if you could share your thoughts on that. Thks for the great video!
@isurujn
@isurujn 2 жыл бұрын
Thanks for the tutorial. I do have a question. This approach kind of goes against dependancy injection pattern, doesn't it? Having a global object that exposes all its members to anything is the opposite of DI, right? Isn't it bad?
@nbits7433
@nbits7433 2 жыл бұрын
Quality content. Thank you.
@winniecole7276
@winniecole7276 6 ай бұрын
Very informative 👏
@Vlad100333
@Vlad100333 2 жыл бұрын
Really cool, thanks my dear friend
@saliouseck4263
@saliouseck4263 3 жыл бұрын
thank's very much very clear
@user-kw9cu
@user-kw9cu 2 жыл бұрын
thank you i get it
@Flutterdev6391
@Flutterdev6391 3 жыл бұрын
Thanks
@hasankemalturk4416
@hasankemalturk4416 2 жыл бұрын
Thanks to you :)
@moazelsawaf2000
@moazelsawaf2000 Жыл бұрын
Thanks a lot ❤
@ben6
@ben6 3 жыл бұрын
ServiceLocator seems to be "god-singleton" class. Never did i think of using 2 really bad words in programming at the same time.
@FlutterExplained
@FlutterExplained 3 жыл бұрын
Hi Ben, thanks for your feedback and your concern, maybe I did not explain it correctly but ServiceLocator is not a God Singleton, it is a registration library for singletons. Maybe I did not use it perfectly here in the video but this is a general idea. The pattern exists already quite some time but it is pretty much debated. In my research, I talked with a lot of people and figured out that there are a lot of people who love it and a lot who hate it. In my opinion, it heavily depends on your use case and how you and your team want to work. I hope that clarifies things :) en.wikipedia.org/wiki/Singleton_pattern
@kopianan
@kopianan 3 жыл бұрын
hi there, how to unregister singleton using injectable ?
@ziyadmansy6016
@ziyadmansy6016 2 жыл бұрын
What are the use cases of this when i can normally use the normal dependency injection in Provider for example? any singleton class would do that then where is the advantage?
@FlutterExplained
@FlutterExplained 2 жыл бұрын
Very good question, of course you are able to use provider for that. It is even nearly the same idea. It is more about what tool to use for which problem. Get_it is specifically for DI while Provider should be a state management solution.
@thomasmoore2870
@thomasmoore2870 2 жыл бұрын
Thanks!!
@caballero75RS
@caballero75RS 3 жыл бұрын
Great class. I would like to see now an integration with provider for state management. Could i use 'with changeNotifier' in MemeRepo class? Thanks
@burakbirer
@burakbirer 3 жыл бұрын
That would be get_it_mixin i guess?
@FlutterExplained
@FlutterExplained 3 жыл бұрын
​@@burakbirer Yes get_it_mixin will do the job!
@escamoteur
@escamoteur 3 жыл бұрын
Directly combining with provider doesn't make much sense. But state_notifier would be an option. But I highly recommend to check out the get_it_mixin which makes get_it to a full state management solution.
@burakbirer
@burakbirer 3 жыл бұрын
@@escamoteur then we absolutely need a detailed video about best practices with get_it_mixin 💙
@burakbirer
@burakbirer 3 жыл бұрын
@@FlutterExplained May we take your answer as an upcoming tutorial on get_it_mixin ? That would be great!
@tawandagutsa5993
@tawandagutsa5993 3 жыл бұрын
Excellent video! I do have a question though, if you can help. I was hoping get_It would be a state management solution that automatically updates the UI when changes are made like provider with notifylisteners, without the context from a widget being required. You've made it clear it's not. Are there any state management packages that can do the same thing provider can do, but without the context? Thanks in advance
@FlutterExplained
@FlutterExplained 3 жыл бұрын
You can actually use GetIT also as a state management solution nowadays you will need to use the package: get_it_mixing pub.dev/packages/get_it_mixin
@hamourabimr3826
@hamourabimr3826 Жыл бұрын
Hi.. Would like to know the config you used with your vscode? Theme, font.. thanks
@FlutterExplained
@FlutterExplained Жыл бұрын
I use in general Fire font with nerd icons and as a Theme I am using usually the One Dark Theme.
@jai6133
@jai6133 3 жыл бұрын
Can you make an video for getit with provider ?
@ElVerdaderoAbejorro
@ElVerdaderoAbejorro Жыл бұрын
Please don't mislead non-senior devs into thinking this is dependency injection. A service locator is not the same as dependency injection. SL is actually an anti pattern (the book "Dependency Injection: Principles, Practices and Patterns" explains why). For a real DI library for Dart/Flutter see Inject.
@FlutterExplained
@FlutterExplained Жыл бұрын
Thanks for your feedback. You are right the Service Locator Pattern (SL) can be a anti pattern because its over usage but I would not generalize it as "you should never use it because it is bad". I know also a lot of large project who overuse, and overcomplicated with a SL but there are as always some nice niche cases for it (especially in Server Dev). Sorry if I made that not super clear in the video, maybe I can create a follow up in the next month :).
@user-su4yk5ph6v
@user-su4yk5ph6v 3 жыл бұрын
👍🏻
@numberone6660
@numberone6660 3 жыл бұрын
Why we not just create a meme object and to use getMeme?
@FlutterExplained
@FlutterExplained 3 жыл бұрын
Great question, the problem is if you directly create the MemeRepo or MemeDomainController object and get the meme you have a strong dependency between both, this means if you want to for example create a Test you will have no chance to replace the Services with something you like. Therefore you will have to test the whole application rather then only the function. You can find more to this topic if you search for Dependency Injection: martinfowler.com/articles/injection.html
@user-kh6rp6yx1j
@user-kh6rp6yx1j 2 ай бұрын
Hello man.
@rudranshawasthi7291
@rudranshawasthi7291 3 жыл бұрын
I have a quesion why did we not use a memeDomainCOntroler when we could directly call the meme repo as thats what is happening.
@jutt342
@jutt342 2 жыл бұрын
I have a question pls guide, how GetIt handles garbage collector as it registeres so many object before hand does it mean all those objects will remain in memory till app lifecycle ? or Objects will be wiped off by garbage collector if yes then when pls guide
@FlutterExplained
@FlutterExplained 2 жыл бұрын
Very good question, AFAIK if you will not clean them up they will stay in Memory you will need to create some kind of mechanism to clean them up. Lazy loading Singeltons will be created when they are needed but will also leave a footprint afterwards.
@syahrul7493
@syahrul7493 3 жыл бұрын
Please subtitle on you video. Im from indonesia
@francescofreddi4374
@francescofreddi4374 3 жыл бұрын
but..... all benefit about stateManagement is broken by setState........
@FlutterExplained
@FlutterExplained 3 жыл бұрын
Get_It is not a state management solution. Therefore it is not really broke. It is a service provider, and you have access to different layers. If you search for a state management solution, please have a look into get_it_mixins :)
@francescofreddi4374
@francescofreddi4374 3 жыл бұрын
@@FlutterExplained you have reason!! mmmm more of less is like Provider... right?
@escamoteur
@escamoteur 3 жыл бұрын
@@francescofreddi4374 yes, but you don't need a Buildcontext and it offers some other nice functionality. together with the get_it_mixin it gets a full state mangement solution
@askin_bilir
@askin_bilir 3 жыл бұрын
I think Get X could be a better alternative because many things can be done with one package
@FlutterExplained
@FlutterExplained 3 жыл бұрын
AFAIK GetX would also solve this problem because it has a strong DI implementation. However I am personally not a big fan of GetX.
@_undecided
@_undecided 3 жыл бұрын
GetX is most bloatware state management for me and people are deceived because not need use context and very short lines. Remember what I say. Using GetX without context is dangerous with Responsive Layouts and what is short and simple is not mean best it will eat your errors in the background or can be hard to test and.... Even Bloc is better choose. But of course it's you choose.
@askin_bilir
@askin_bilir 3 жыл бұрын
@@_undecided For state management I prefer flutter block or provider. I have never used GetX in a real project. I just saw its popularity, usability and features. These options was catchy for me. If you are saying these, probably you had tested it.
@leoingson
@leoingson 3 жыл бұрын
​@@FlutterExplained Hey, care to elaborate why you're not the biggest fan? I've seen some reservations, but GetX seemed to be a state management candidate.. Paar kurze Worte reichen :)
@FlutterExplained
@FlutterExplained 3 жыл бұрын
​@@leoingson Hi there, sure. GetX is an amazing package but also a great example of a so-called golden hammer pattern. It promises everything out of the box and a lot of people will tend to use it. The problem is that you create another strong dependency between your project and GetX. So let's say I managed my State with GetX now something goes wrong in GetX and I strongly depend on the library, what happens if the main maintainer of the package is gone? Can I replace GetX easily? Do I understand the core of GetX. What happens if the GetX team drives a decision I am not willing to take in my application. Suddenly I have to remove the whole package and because it is everywhere, basically I will throw away my application. If I would take a package that has only one single responsibility, that does not violate the Single Responsibility Principle. It is way easier to substitute it with something else. You could argue that you only want to use GetX for a single purpose, but even there if you have a team you can maybe speak for yourself, but you cannot make sure that nobody will use the offered power. GetX remembers me a lot to jQuery, it also offered a lot and made it possible to wrap most of your JavaScript code, but boy it was horrible when we needed to get rid of it. This is just my opinion, and I will also create sooner or later a video where I talk a bit more in deep about it.
Dependency Injection in Flutter - You HAVE to Use it !
7:07
Flutter Guys
Рет қаралды 17 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 801 М.
Records & Patterns - Get started with the newest addition in Dart 3.0
11:30
Flutter Explained
Рет қаралды 2,3 М.
Dependency Injections Using Get It👋
12:31
Abhishvek
Рет қаралды 7 М.
Dependency Injection in Flutter using GetIt | Flutter Package
4:43
AI with Flutter
Рет қаралды 3,6 М.
Learn to use Isolates in Flutter | Simplified
10:28
CodeX
Рет қаралды 25 М.