getUserType method

Future<UserType?> getUserType(
  1. String uid
)

Retrieves the user type for a given user ID from Firestore.

Parameters:

  • uid: The ID of the user whose type is to be retrieved.

Returns: A Future<UserType?> containing the user's type, or null if the operation fails.

Implementation

Future<UserType?> getUserType(String uid) async {
  try {
    DocumentSnapshot doc =
        await _firestore.collection('users').doc(uid).get();
    return UserTypeExtension.fromString(doc['userType']);
  } catch (e) {
    return null;
  }
}