'a document path must be a non-empty string-error

a document path must be a non-empty string
'package:cloud_firestore/src/collection_reference.dart':
Failed assertion: line 116 pos 14: 'path.isNotEmpty'

I'm getting above error in my code. don't know where to fix this. here you can find the full code of my conversaton.dart file. ConversationScreen.dart... also on the emulator it has display this error. does anyone know how to fix this.

emulator error

  sendMessage(){
    if (messageController.text.isNotEmpty){
      Map<String,String> messageMap ={
        "message": messageController.text,
        "sendBy" : Constants.myName
      };
      databaseMethods.addConversationMessages(widget.chatRoomId, messageMap);
      messageController.text = "";
    }
  }


Solution 1:[1]

ChatMessageList() {
  return StreamBuilder<QuerySnapshot>(
    stream: chatMessagesStream,
    builder: (context, snapshot) {
     // check whether the doc is empty first
         print((snapshot.data! as QuerySnapshot).docs); 
         return ListView.builder(
           itemCount: (snapshot.data! as QuerySnapshot).docs.length,

             itemBuilder:(context, index){

             return MessageTile(snapshot.data!.docs[index]["message"],);
             });
    },
  );
}

Check this first

Also,

var docRef = FirebaseFirestore.instance
          .collection('Message')
           /// check if you have passed the correct id
          .doc(groupChatId)   
          .collection(groupChatId)

Similar issue : a document path must be a non-empty string 'package:cloud_firestore/src/collection_reference.dart'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harish