How to solve error Paths must not contain // in them. Firestore flutter error

安稳与你 提交于 2020-07-22 08:28:23

问题


I am not including // in my path.But still i am getting error from firestore that Paths must not contain // in them

onPressed: (){
    opencheckout();
    setState(() {
        _firestore.collection('userss').document(uid)
            .collection('OrdersSuccess').add({
                "name":product.name,
                "original":product.original,
                "Quantity":product.Quantity,
                "image":product.image,
            });
    });
};

Debug console Message

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)


回答1:


Read the error message carefully:

Invalid path (userss//OrdersSuccess/Iy4M9nYayqCAk0EcCKEB). Paths must not contain // in them.

Here's the query:

_firestore.collection('userss').document(uid).collection('OrdersSuccess')

It looks like your uid might be an empty string, which causes the two surrounding slashes to collapse into //. So, check uid by using a debugger or printing it, and make sure it contains what you expect.



来源:https://stackoverflow.com/questions/61962393/how-to-solve-error-paths-must-not-contain-in-them-firestore-flutter-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!