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

Viewed 1174

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 Answers

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.

Related