injectable
injectable copied to clipboard
How to implement open generics?
Let's assume I have an interface ILogger<T>
and this implementation:
final class Logger<T> implements ILogger<T> {
const Logger();
void print(String message) {
// From dart:dev:
log(message, name: T.toString());
}
}
I want to be able to use that class with open generics (a concept in C# that allows, for instance, registration of a dependency of type ILogger<>
: the missing T meaning "any type").
So, in some service, I would do:
final class SomeService {
const SomeService({required this.logger});
final ILogger<SomeService> logger;
}
So this particular service would print stuff such as
[SomeService] Some log message
Is there some way to accomplish that?
Hey @JCKodel this needs to be supported by get_it first.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions