onBind method

void onBind(
  1. AirDI di
)

Synchronous configuration and dependency registration.

This is the first method called in the module lifecycle. It MUST be strictly synchronous to ensure fast module registration.

Responsibility: Define "how" to create dependencies (blueprints).

  • Register Singletons or Factories in AirDI.
  • Do NOT perform asynchronous operations or heavy initialization here.

If a service requires async setup (e.g., SharedPreferences, DB), register the class/service here and handle its initialization in onInit.

di The dependency injection container instance.

Implementation

void onBind(AirDI di) {
  _state = ModuleLifecycleState.binding;
  debugPrint('[$id] onBind');
  _state = ModuleLifecycleState.bound;
}