Service registration at runtime
Register a service with a factory while the app is running.
Sometimes you need to register services at runtime. For this, you can use the register method:
void main() {
var container = ServiceContainer();
container.register(
(container) => MySelfRegisteredService(container.resolve()),
);
var selfRegistered = container.resolve<MySelfRegisteredService>();
selfRegistered.sayHello();
}