11111
This commit is contained in:
41
lib/core/di/injection_container.dart
Normal file
41
lib/core/di/injection_container.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../network/api_client.dart';
|
||||
|
||||
final sl = GetIt.instance;
|
||||
|
||||
Future<void> initializeDependencies() async {
|
||||
// External
|
||||
sl.registerLazySingleton<Dio>(() => Dio());
|
||||
|
||||
// SharedPreferences
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
sl.registerLazySingleton<SharedPreferences>(() => sharedPreferences);
|
||||
|
||||
// Core
|
||||
sl.registerLazySingleton<ApiClient>(() => ApiClient(dio: sl()));
|
||||
|
||||
// Data sources will be registered here
|
||||
// Example:
|
||||
// sl.registerLazySingleton<AuthRemoteDataSource>(
|
||||
// () => AuthRemoteDataSourceImpl(apiClient: sl()),
|
||||
// );
|
||||
|
||||
// Repositories will be registered here
|
||||
// Example:
|
||||
// sl.registerLazySingleton<AuthRepository>(
|
||||
// () => AuthRepositoryImpl(
|
||||
// remoteDataSource: sl(),
|
||||
// localDataSource: sl(),
|
||||
// ),
|
||||
// );
|
||||
|
||||
// Use cases will be registered here
|
||||
// Example:
|
||||
// sl.registerLazySingleton(() => LoginUseCase(repository: sl()));
|
||||
|
||||
// Blocs will be registered here
|
||||
// Example:
|
||||
// sl.registerFactory(() => LoginBloc(loginUseCase: sl()));
|
||||
}
|
||||
Reference in New Issue
Block a user