Flutterando / auto_injector

Dependency injection system. But without build_runner :)
https://pub.dev/packages/auto_injector
Other
54 stars 15 forks source link

Lazy Singleton + Inversion of Control #1

Closed davidsdearaujo closed 1 year ago

davidsdearaujo commented 1 year ago

When we try to register a lazy singleton class with inversion of control, it doesn't works. Look this example:

abstract class InversionOfControlInterface {}
class Implementation implements InversionOfControlInterface {} 

void main() {
  final injector = AutoInjector();
  injector.addLazySingleton<InversionOfControlInterface>(Implementation.new);
  injector.commit();

  final instance = injector.get<InversionOfControlInterface>();
}

It throws an error at the last line: InversionOfControlInterface unregistered.