onDispose method

Future<void> onDispose()

Invoked when the module is unregistered from the registry or explicitly disposed.

Cancels all active event stream subscriptions and closes stream controllers.

Implementation

Future<void> onDispose() async {
  for (final sub in _nativeSubscriptions.values) {
    await sub.cancel();
  }
  _nativeSubscriptions.clear();

  for (final controller in _streamControllers.values) {
    await controller.close();
  }
  _streamControllers.clear();
  _isInitialized = false;
}