kiwi 4.0.0 kiwi: ^4.0.0 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 {}