I am building a part for an app which is a chat app system, but am kinda lost.
The post request code to firebase
FirebaseFirestore.instance
.collection('messages')
.doc(user.uid)
.collection(widget.receiver)
.add({
'message': _textEditingController.text,
'messageType': "sender",
'receiver': widget.receiver,
'sender': user.uid,
'timestamp': DateTime.now()
.millisecondsSinceEpoch
.toString(),
});
To fetch the messages
FirebaseFirestore.instance
.collection('messages')
.doc(user.uid)
.collection(widget.receiver)
.where('receiver', isEqualTo: widget.receiver)
.snapshots(),
The message sends, but if i want to retrieve it for one on one use it doesn't display. Am i doing something wrong?