onDispose method

  1. @mustCallSuper
Future<void> onDispose(
  1. AirDI di
)

Resource cleanup when the module is being removed.

This method is called by ModuleManager.unregister. It handles:

Note: Always call super.onDispose(di) if you override this.

di The dependency injection container instance.

Implementation

@mustCallSuper
Future<void> onDispose(AirDI di) async {
  _state = ModuleLifecycleState.disposing;
  debugPrint('[$id] onDispose');

  // Clean up event subscriptions
  EventBus().cancelModuleSubscriptions(id);

  // Clean up services
  SecureServiceRegistry().unregisterModuleServices(id);

  _state = ModuleLifecycleState.disposed;
}