[Discussion] GetIt best practices
Some Background
I have used this awesome state management approach for quite some time. Its minimalism and usage outside BuildContext is superb.
This point is unrelated to the question: at times GetIt wouldn't cut it I had to use InheritedWidget when passing state to a modular widget that can have more than one instance of it showing simultaneously. Think multiple ProductDetailsWidget's inside a list or a single ProductDetailsWidget inside its standalone page. I understand scoped model approach but still multiple instances show on the screen at once, and state (ViewModel) cannot be accessed via a single instance.
Questions Context
When you have a modular widget, page widget, view model, or service/repository that references multiple services/repositories. It feels a bit not optimal structure-wise. As in you can't tell for sure what the dependencies are for this widget or service in question. You have to find occurrences of getIt<T> throughout the file to understand its dependencies.
Questions
- So what are the best practices to organize dependencies for a class/widget?
- Any additional best practices to structure things better and allow better collaboration and higher maintainability is welcomed.
Are you aware that you can register multiple instances of the same type using the name parameter to distinguish them?