onInit method

Future<void> onInit(
  1. AirDI di
)

Asynchronous initialization logic for the module.

Called after onBind and after all mandatory dependencies have been fully initialized.

Responsibility: Perform the "heavy lifting" and preparation.

  • Initialize databases, local storage, or remote configurations.
  • Load initial state data or establish connections.

This is the correct place to await for services registered in onBind to be ready before the module is marked as ModuleLifecycleState.initialized.

di The dependency injection container instance.

Implementation

Future<void> onInit(AirDI di) async {
  _state = ModuleLifecycleState.initializing;
  debugPrint('[$id] onInit');
  _state = ModuleLifecycleState.initialized;
}