hello i am buliding a simple chatting app. in my apis.dart folder i have created sendmessaage function but in await ref.doc(time).set(messeges.toJson()); this line it showing me a error of error: The method ‘doc’ isn’t defined for the type ‘Stream’. so plz help me i am new at flutter and stack overflow platform help me.
static Future<void> sendmessages(chatusres chuser, String msg) async {
final time = DateTime.now().millisecondsSinceEpoch.toString();
final Messeges messeges = Messeges(
fromid: user.uid,
msg: msg,
read: '',
sent: time,
toid: chuser.id,
type: '');
final ref = firestore
.collection('chats/${getconversationid(user.uid)}/messages}')
.snapshots();
await ref.doc(time).set(messeges.toJson());
}
New contributor
Vinay Chavhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.