fixed login bug

This commit is contained in:
amirrezaghabeli
2025-08-21 10:59:28 +03:30
parent e5295e0eea
commit f81e9dd32d
4 changed files with 21 additions and 6 deletions
+9 -3
View File
@@ -8,16 +8,20 @@ import '../core/utils/result.dart';
import '../data/repositories/profile_repository.dart';
import '../data/services/model/logout_response/logout_response.dart';
import '../data/services/model/profile_response/profile_response.dart';
import 'auth_view_model.dart';
class ProfileViewModel with ChangeNotifier {
final ProfileRepository _profileRepository;
final AuthRepository _authRepository;
final AuthViewModel _authViewModel;
ProfileViewModel({
required ProfileRepository profileRepository,
required AuthRepository authRepository,
required AuthViewModel authViewModel,
}) : _profileRepository = profileRepository,
_authRepository = authRepository {
_authRepository = authRepository,
_authViewModel = authViewModel {
getCompanyProfile();
}
@@ -81,7 +85,7 @@ class ProfileViewModel with ChangeNotifier {
notifyListeners();
}
Future<void> logout(BuildContext context) async {
Future<void> logout() async {
_errorMessage = null;
notifyListeners();
@@ -89,13 +93,15 @@ class ProfileViewModel with ChangeNotifier {
switch (result) {
case Ok<LogoutResponse>():
localLogout();
_authViewModel.localLogout();
_loggedOut = true;
break;
case Error<LogoutResponse>():
_errorMessage = result.error.toString();
break;
}
notifyListeners();
_errorMessage = null;
notifyListeners();
}