import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:get_it/get_it.dart'; import '../../features/auth/data/datasources/auth_remote_datasource.dart'; import '../../features/auth/data/repositories/auth_repository_impl.dart'; import '../../features/auth/domain/repositories/auth_repository.dart'; import '../network/dio_client.dart'; import '../network/network_info.dart'; import '../storage/secure_storage.dart'; /// Service locator instance final sl = GetIt.instance; /// Initialize all dependencies /// /// This function registers all the dependencies required by the app /// in the GetIt service locator. Call this in main() before runApp(). Future initDependencies() async { // ===== Core ===== // Connectivity (external) - Register first as it's a dependency sl.registerLazySingleton( () => Connectivity(), ); // Network Info sl.registerLazySingleton( () => NetworkInfo(sl()), ); // Dio Client sl.registerLazySingleton( () => DioClient(), ); // Secure Storage sl.registerLazySingleton( () => SecureStorage(), ); // ===== Authentication Feature ===== // Auth Remote Data Source sl.registerLazySingleton( () => AuthRemoteDataSourceImpl(dioClient: sl()), ); // Auth Repository sl.registerLazySingleton( () => AuthRepositoryImpl( remoteDataSource: sl(), secureStorage: sl(), dioClient: sl(), ), ); // ===== Data Sources ===== // Note: Other data sources are managed by Riverpod providers // No direct registration needed here // ===== Repositories ===== // TODO: Register other repositories when they are implemented // ===== Use Cases ===== // TODO: Register use cases when they are implemented // ===== Providers (Riverpod) ===== // Note: Riverpod providers are registered differently // This is just for dependency injection of external dependencies } /// Clear all dependencies (useful for testing) void resetDependencies() { sl.reset(); }