0

I am currently trying to develop a random chat application which matches users randomly and allows them to chat and then add each other as friends (if they enjoyed the chat) in order to continue the chat.

So now I need to solve three problems:

  1. match users randomly

My idea would be to implement a method which randomly picks two user ids from my users collection. But I do not know how to implement this in code - Can anybody help here?

  1. craete a chat room to store the messages

This is the most difficult part. Currently my idea is to create a collection called "chats" and add a document which is named "$uid of user 1 & $uid of user2" where I save the messages. But I do not know how that would look in code and whether this actually solves the problem.

  1. create a friend list

My idea is to create a list inside each user document and save the user ids of all friends. How could that be implemented in code? And is there a better solution to that?

Sathi Aiswarya
  • 2,068
  • 2
  • 11
cipano
  • 107
  • 1
  • 8
  • 1
    For #2, the approach sounds good, and you can find a code sample here: https://stackoverflow.com/questions/33540479/best-way-to-manage-chat-channels-in-firebase. If you're having trouble implementing that in Flutter, open a new question with a [minimal repro](http://stackoverflow.com/help/mcve) of where you got stuck. – Frank van Puffelen Oct 13 '22 at 22:29

0 Answers0