configureDependencies function

Future<void> configureDependencies({
  1. required AppEnvironment environment,
  2. FirebaseRemoteConfig? firebaseRemoteConfig,
})

Registers all application dependencies with getIt for the given environment.

Must be called once during app initialisation, before any service is accessed. Registration proceeds in dependency order:

  1. Logging (AppLogger / SentryAppLogger) — registered first so all subsequent steps can report errors.
  2. Async foundations — SharedPreferences, documents path, and FirebaseRemoteConfigService are queued concurrently.
  3. Core infrastructure — SecureStorage, TokenStorageService, SecurityChecker.
  4. Utilities — ToastService, AuthFailureNotifier.
  5. Network — Dio interceptors and three named Dio clients (publicDio, authenticatedDio, refreshDio).
  6. API services — AuthService, UserService.
  7. Repositories — UserRepository, AuthRepository, NotificationRepository, ImagePickerAndCropperRepository.

Call getIt.allReady() after this function returns to block until all async singletons have completed their initialisation.

firebaseRemoteConfig overrides the FirebaseRemoteConfig instance used by Remote Config registration — defaults to FirebaseRemoteConfig.instance in production. Exists solely so tests can inject a mock without requiring a real initialised Firebase app, matching the same testability pattern as configureCertificatePinning's allowedFingerprints parameter.

Implementation

Future<void> configureDependencies({required AppEnvironment environment, FirebaseRemoteConfig? firebaseRemoteConfig}) async {
  // 1. Logging — registered first so every subsequent step can report errors.
  //    SentryAppLogger has no async setup; Sentry is already initialised before
  //    this function is called.
  _registerLogging();

  // 2. Async foundations — platform paths, preferences, Firebase.
  //    registerSingletonAsync queues the async work and returns immediately;
  //    the actual completion is awaited by getIt.allReady() in app_config.dart.
  //    All three start concurrently.
  _registerAsyncSingletons();
  _registerFirebaseServices(environment: environment, firebaseRemoteConfig: firebaseRemoteConfig);

  // 3. Core infrastructure — storage, token, security, utilities.
  _registerCoreDependencies();
  _registerUtilities();

  // 4. Network layer — Dio clients and interceptors.
  _registerNetworkClients(environment: environment);

  // 5. Services and repositories — depend on everything above.
  _registerApiServices();
  _registerRepositories();
}