fetchUser method
Implementation
Future<User?> fetchUser() async {
if (!isAuthenticated) {
return null;
}
try {
User user =
await _apiService.getModelRequest('v1/users/me', User.fromJson);
print("Fetched user: ");
print(user);
// Set the user details in the analytics service
_analyticsService.setUserProperties(userId: user.id.toString());
// Save the user details in this auth service
_currentUser = user;
return user;
} catch (err) {
return null;
}
}