|
|
|
|
import 'package:get_it/get_it.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/api/api_client.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_repo.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/common/common_repo.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_repo.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/analytics/analytics_service.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/cache_service.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/logger_service.dart';
|
|
|
|
|
import 'package:logger/web.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
|
|
GetIt getIt = GetIt.instance;
|
|
|
|
|
|
|
|
|
|
class AppDependencies {
|
|
|
|
|
static Future<void> addDependencies() async {
|
|
|
|
|
// Services
|
|
|
|
|
getIt.registerLazySingleton<LoggerService>(() => LoggerServiceImp(logger: Logger(printer: PrettyPrinter(
|
|
|
|
|
methodCount: 2, // number of stack trace lines
|
|
|
|
|
errorMethodCount: 5, // number of stack trace lines for errors
|
|
|
|
|
lineLength: 100, // wrap width
|
|
|
|
|
colors: true, // colorful logs
|
|
|
|
|
printEmojis: true, // include emojis
|
|
|
|
|
),)));
|
|
|
|
|
final sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
|
getIt.registerLazySingleton<CacheService>(() => CacheServiceImp(sharedPreferences: sharedPreferences));
|
|
|
|
|
getIt.registerSingleton(AppState());
|
|
|
|
|
getIt.registerSingleton(GAnalytics());
|
|
|
|
|
getIt.registerLazySingleton<ApiClient>(() => ApiClientImp(loggerService: getIt()));
|
|
|
|
|
|
|
|
|
|
// Repositories
|
|
|
|
|
getIt.registerLazySingleton<CommonRepo>(() => CommonRepoImp(loggerService: getIt()));
|
|
|
|
|
getIt.registerLazySingleton<AuthenticationRepo>(() => AuthenticationRepoImp(loggerService: getIt<LoggerService>(), apiClient: getIt()));
|
|
|
|
|
getIt.registerLazySingleton<BookAppointmentsRepo>(() => BookAppointmentsRepoImp(loggerService: getIt<LoggerService>(), apiClient: getIt()));
|
|
|
|
|
getIt.registerLazySingleton<MyAppointmentsRepo>(() => MyAppointmentsRepoImp(loggerService: getIt<LoggerService>(), apiClient: getIt()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|