Is it ok to use both GetX and Get_it at the same time?

Viewed 1714

I want to use GetX in my flutter project for state management. I don't know how I can achieve dependency injection with GetX though. Is it ok to use Get_it along with GetX in the same project? I feel like doing so makes the code cluttered. Or should I create a binding class with GetX and use it as initialBinding to achieve dependency injection?

I want to be able to inject dependencies into non-view classes. What is the best practice for this?

Using GetX + Get_it or is it possible with GetX alone?

Thanks

1 Answers

It is possible to just use GetX and still be able to access dependencies form outside the widget tree.

///Inject
Get.put(CartService());
///Retrieve
CartService cartService = Get.find();

GetX has a built in service locator just as Get_it works. Although they don't share the same features the one you are looking for GetX does the trick.

You could use both, but if GetX already has this functionality built in and it works correctly I don't see why you would need to access get _it.(Maybe to use injectable?)

Related