configureDependencies function
- required AppEnvironment environment,
- 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:
- Logging (AppLogger / SentryAppLogger) — registered first so all subsequent steps can report errors.
- Async foundations — SharedPreferences, documents path, and FirebaseRemoteConfigService are queued concurrently.
- Core infrastructure — SecureStorage, TokenStorageService, SecurityChecker.
- Utilities — ToastService, AuthFailureNotifier.
- Network — Dio interceptors and three named Dio clients (
publicDio,authenticatedDio,refreshDio). - API services — AuthService, UserService.
- 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();
}