getUserProfile method

Future<UserProfileModel?> getUserProfile(
  1. String userId
)

Implementation

Future<UserProfileModel?> getUserProfile(String userId) async {
  final doc = await _firestore.collection('users').doc(userId).get();
  if (!doc.exists) return null;

  final user = UserProfileModel.fromFirestore(doc);
  // If server sent role: "superAdmin", user.role will be null (safe!)
  // App continues working, and you can handle null role in UI

  return user;
}