fetchUserProfile method
Fetches the current user's profile data from Firestore.
Returns: A Future<UserModel?> containing the user's profile, or null if the operation fails or no user is signed in.
Implementation
Future<UserModel?> fetchUserProfile() async {
try {
final currentUser = FirebaseAuth.instance.currentUser;
if (currentUser == null) return null;
final doc = await FirebaseFirestore.instance
.collection('users')
.doc(currentUser.uid)
.get();
return UserModel.fromMap(doc.data() ?? {});
} catch (e) {
print('Error fetching profile: $e');
return null;
}
}