dispose method
🗑️ Dispose all singletons or scope. Warning: don't use this on your root container. You should only use this on scoped containers.
Implementation
Future<void> dispose() async {
assert(isScoped, 'Only dispose scoped containers');
for (final type in singletons.keys) {
//Note: we don't need to check if the service is a singleton because
//singleton service definitions never have dispose
final serviceDefinition = serviceDefinitionsByType[type]!;
//We can't do a null check here because if a Dart issue
serviceDefinition._dispose.call(singletons[type]);
await serviceDefinition._disposeAsync(singletons[type]);
}
singletons.clear();
}