dispose method

Future<void> dispose()

Disposes of all locally registered instances that implement Disposable.

Implementation

Future<void> dispose() async {
  for (var instance in _instances.values.toList()) {
    if (instance is Disposable) {
      try {
        await instance.dispose();
      } catch (e) {
        // In a framework, we should probably log this but not let it crash the request loop
      }
    }
  }
  _instances.clear();
}