dispose method

Future<void> dispose()

Disposes all active stream controllers.

This method iterates through all stored stream controllers, closes each one asynchronously, and then clears the _controllers map.

It should be called when the instance is no longer needed to release resources and prevent memory leaks.

Returns:

  • A Future<void> indicating when all controllers have been closed.

Implementation

Future<void> dispose() async {
  for (final StreamController<Map<String, dynamic>> controller
      in _controllers.values) {
    await controller.close();
  }
  _controllers.clear();
}