Refactor dependency injection to use lazy loading for providers in the core configuration. Remove unused logout method from AuthViewModel and adjust ProfileViewModel to call localLogout directly from AuthRepository. Clean up constructor parameters in ProfileViewModel and TenderDetailViewModel by removing unnecessary dependencies.
This commit is contained in:
@@ -37,47 +37,65 @@ List<SingleChildWidget> get providersRemote {
|
||||
|
||||
List<SingleChildWidget> get cores {
|
||||
return [
|
||||
Provider(create: (context) => NetworkManager(context.read())),
|
||||
ChangeNotifierProvider(create: (context) => ThemeProvider()),
|
||||
ChangeNotifierProvider(create: (context) => NotificationStateService()),
|
||||
Provider(create: (context) => NetworkManager(context.read()), lazy: true),
|
||||
ChangeNotifierProvider(create: (context) => ThemeProvider(), lazy: true),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => NotificationStateService(),
|
||||
lazy: true,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<SingleChildWidget> get apiClients {
|
||||
return [
|
||||
Provider(create: (context) => AuthService(networkManager: context.read())),
|
||||
Provider(create: (context) => HomeService(networkManager: context.read())),
|
||||
Provider(
|
||||
create: (context) => AuthService(networkManager: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create: (context) => HomeService(networkManager: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create: (context) => TenderDetailService(networkManager: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
|
||||
Provider(
|
||||
create: (context) => YourTendersService(networkManager: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create: (context) => LikedTendersService(networkManager: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create: (context) => TendersService(networkManager: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create: (context) => ProfileService(networkManager: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create: (context) => NotificationsService(networkManager: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<SingleChildWidget> get repositories {
|
||||
return [
|
||||
Provider(create: (context) => AuthRepository(authService: context.read())),
|
||||
Provider(
|
||||
create: (context) => AuthRepository(authService: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create:
|
||||
(context) => YourTendersRepository(
|
||||
yourTendersService: context.read(),
|
||||
likedTendersService: context.read(),
|
||||
),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create:
|
||||
@@ -85,28 +103,33 @@ List<SingleChildWidget> get repositories {
|
||||
homeService: context.read(),
|
||||
yourTendersService: context.read(),
|
||||
),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create:
|
||||
(context) =>
|
||||
TenderDetailRepository(tenderDetailService: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
|
||||
Provider(
|
||||
create:
|
||||
(context) =>
|
||||
LikedTendersRepository(likedTendersService: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create: (context) => TendersRepository(tendersService: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create: (context) => ProfileRepository(profileService: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
Provider(
|
||||
create:
|
||||
(context) =>
|
||||
NotificationsRepository(notificationsService: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -119,6 +142,7 @@ List<SingleChildWidget> get services {
|
||||
homeRepository: context.read(),
|
||||
notificationStateService: context.read(),
|
||||
),
|
||||
lazy: true,
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -127,6 +151,7 @@ List<SingleChildWidget> get viewModels {
|
||||
return [
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => AuthViewModel(authRepository: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create:
|
||||
@@ -134,23 +159,25 @@ List<SingleChildWidget> get viewModels {
|
||||
homeRepository: context.read(),
|
||||
notificationStateService: context.read(),
|
||||
),
|
||||
lazy: true,
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => TendersViewModel(tendersRepository: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create:
|
||||
(context) => TenderDetailViewModel(
|
||||
tenderDetailRepository: context.read(),
|
||||
tendersRepository: context.read(),
|
||||
tendersViewModel: context.read(),
|
||||
),
|
||||
lazy: true,
|
||||
),
|
||||
|
||||
ChangeNotifierProvider(
|
||||
create:
|
||||
(context) =>
|
||||
YourTendersViewModel(yourTendersRepository: context.read()),
|
||||
lazy: true,
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create:
|
||||
@@ -158,17 +185,19 @@ List<SingleChildWidget> get viewModels {
|
||||
likedTendersRepository: context.read(),
|
||||
tendersRepository: context.read(),
|
||||
),
|
||||
lazy: true,
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create:
|
||||
(context) => ProfileViewModel(
|
||||
profileRepository: context.read(),
|
||||
authRepository: context.read(),
|
||||
authViewModel: context.read(),
|
||||
),
|
||||
lazy: true,
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => FinalCompletionOfDocumentsViewModel(),
|
||||
lazy: true,
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create:
|
||||
@@ -177,6 +206,7 @@ List<SingleChildWidget> get viewModels {
|
||||
notificationStateService: context.read(),
|
||||
notificationCheckService: context.read(),
|
||||
),
|
||||
lazy: true,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user