For creating API repository, DioClient, Database access class in flutter, we can use singleton pattern and create singleton classes. Then, what is the advantage of using service locators like get_it
.
True, we may not always need it. If you understand how get_it works, you can do some of the simplest things yourself. But it has proven useful because it further provides functionalities that a simple singleton alone may not suffice.
As much as I would love to explain, someone else has taken out time to do this, here is a link
Hope it is helpful