| 1234567891011121314151617181920212223242526 |
- import 'package:get_it/get_it.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'data/datasources/local/shared_prefs.dart';
- import 'data/repositories/auth_repository.dart';
- import 'data/repositories/user_repository.dart';
- import 'presentation/providers/auth_provider.dart';
- import 'presentation/providers/user_provider.dart';
-
- final GetIt sl = GetIt.instance;
-
- Future<void> init() async {
- // External dependencies
- final sharedPreferences = await SharedPreferences.getInstance();
- sl.registerLazySingleton(() => sharedPreferences);
-
- // Data sources
- sl.registerLazySingleton(() => SharedPrefs(sl()));
-
- // Repositories
- sl.registerLazySingleton(() => AuthRepository(localDataSource: sl()));
- sl.registerLazySingleton(() => UserRepository(localDataSource: sl()));
-
- // Providers
- sl.registerFactory(() => AuthProvider(authRepository: sl()));
- sl.registerFactory(() => UserProvider(userRepository: sl()));
- }
|