logout method

Future<void> logout()

Logs out the current user.

It attempts to call the logout API, then clears all authentication data from shared_preferences and resets the provider's state.

Implementation

Future<void> logout() async {
   _setLoading(true);
   try {
     await _apiService.logout();
   } catch (e) {
     debugPrint('Logout API call failed: $e');
   }
   await _clearAuthData();
   _setLoading(false);
 }