getAllUsers method

  1. @override
Future<List<ChatUserModel>> getAllUsers()

Retrieves all users. Used for chat creation.

Implementation

@override
Future<List<ChatUserModel>> getAllUsers() async {
  var currentUser = await getCurrentUser();

  var query = _userCollection.where(
    FieldPath.documentId,
    isNotEqualTo: currentUser?.id,
  );

  var data = await query.get();

  return data.docs.map((user) {
    var userData = user.data();
    return ChatUserModel(
      id: user.id,
      firstName: userData.firstName,
      lastName: userData.lastName,
      imageUrl: userData.imageUrl,
    );
  }).toList();
}