isFriendsWithThisUser method
bool
isFriendsWithThisUser(
- LocalityUser otherUser
)
Implementation
bool isFriendsWithThisUser(LocalityUser otherUser) {
// Check if the owner has sent a friend request to the other user
bool ownerSentRequest = sentFriendRequests.any((friendRequest) =>
friendRequest.sender.id == owner.id && friendRequest.recipient.id == otherUser.id);
// Check if the owner has received a friend request from the other user
bool ownerReceivedRequest = receivedFriendRequests.any((friendRequest) =>
friendRequest.sender.id == otherUser.id && friendRequest.recipient.id == owner.id);
// Both conditions must be true for them to be friends
return ownerSentRequest && ownerReceivedRequest;
}