我的路径中没有包含//。但我仍然从 firestore 收到错误,路径中不得包含//
onPressed: (){
opencheckout();
setState(() {
_firestore.collection('userss').document(uid)
.collection('OrdersSuccess').add({
"name":product.name,
"original":product.original,
"Quantity":product.Quantity,
"image":product.image,
});
});
};
调试控制台消息
E/MethodChannel#plugins.flutter.io/cloud_firestore(12572): java.lang.IllegalArgumentException: Invalid path (userss//OrdersSuccess/Iy4M9nYayqCAk0EcCKEB). Paths must not contain // in them.
E/MethodChannel#plugins.flutter.io/cloud_firestore(12572): at com.google.firebase.firestore.model.ResourcePath.fromString(com.google.firebase:firebase-firestore@@21.3.0:45)
最佳答案
仔细阅读错误消息:
Invalid path (userss//OrdersSuccess/Iy4M9nYayqCAk0EcCKEB). Paths must not contain // in them.
这是查询:
_firestore.collection('userss').document(uid).collection('OrdersSuccess')
看起来您的 uid
可能是一个空字符串,这会导致周围的两个斜杠折叠成 //
。因此,请使用调试器或打印来检查 uid
,并确保它包含您期望的内容。
关于firebase - 如何解决错误 路径中不得包含//。 Firestore 抖动错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61962393/