kiwi 3.0.0-nullsafety.1 kiwi: ^3.0.0-nullsafety.1 copied to clipboard
A simple yet efficient dependency injection container for Dart and Flutter (can be coupled with the kiwi_generator package).
import 'package:kiwi/kiwi.dart';
main() {
KiwiContainer container = KiwiContainer();
container.registerInstance(Logger());
container.registerSingleton((c) => Logger(), name: 'logA');
container.registerFactory((c) => ServiceA(c.resolve<Logger>('logA')));
}
class Service {}
class ServiceA extends Service {
ServiceA(Logger logger);
}
class Logger {}