How is the method being called since the NumberTriviaRepository that is imported is just an abstract class whose implementation is in a completely different file as in the attached issue
Please refer: https://github.com/arc-arnob/clean_code_architecture_tdd_bloc/issues/15
This is a very interesting question. The connection between the abstract class and the concrete implementation is made by dependency injection. Let me give you a brief explanation of my understanding of this code flow. I hope it will clear up your confusion. If you look at the
injection_container.dartfile, you will see thatNumberTriviaRepositoryis registered there and injected with the implementation.injection_container.dart
So when the
GetConcreteNumberTriviause case is invoked as it is also registered ininjection_container.dartas a singleton, it creates a new instance if it doesn't exist or provides a previous instance.While creating that instance, it notices that it needs to inject
NumberTriviaRepository. As it is also registered ininjection_container.dart, it returnsNumberTriviaRepositoryImplementationaccording to the instruction.That's how we can use the
repository.getConcreteNumberTrivia(params.number)function, and the repository we are receiving in the constructor of theGetConcreteNumberTriviaclass is the instance that we created in the injection file. I hope it helps you to understand this topic.