xxxxxxxxxx
import 'package:cloud_firestore/cloud_firestore.dart';
final CollectionReference usersRef = FirebaseFirestore.instance.collection('users');
// Assuming you have the document ID, you can delete it using the delete method
void deleteDocument(String documentId) {
usersRef.doc(documentId).delete().then((value) {
print('Document deleted successfully');
}).catchError((error) {
print('Failed to delete document: $error');
});
}
xxxxxxxxxx
Firestore.instance.collection("chats").document("ROOM_1")
.collection("messages").document(snapshot.data.documents[index]["id"])
.delete();