Home > Software design >  a document path must be a non-empty string 'package:cloud_firestore/src/collection_reference.da
a document path must be a non-empty string 'package:cloud_firestore/src/collection_reference.da

Time:02-14

enter image description here

Widget catageriesList(String airportId, locationId) {
    return Container(
      child: StreamBuilder<QuerySnapshot>(
        stream: FirebaseFirestore.instance.collection("Airport").doc(widget.airportId).collection("location").doc(locationId).collection("Catagorie").snapshots(),
        builder: (context, snapshot) {
          return snapshot.data == null
              ? Container() : ListView.builder(
              itemCount: snapshot.data!.docs.length,
              itemBuilder: (context, index) {
                DocumentSnapshot data = snapshot.data!.docs[index];
                print("object");
                return Catageries(
                  catagerieId: data["Catagorie_id"],
                  catagerieName:  data["Catagorie_name"],
                );
              }
          );
        },
      ),
    );
  }

CodePudding user response:

The error means you're passing null as a document path and this is in this line:

        stream: FirebaseFirestore.instance.collection("Airport").doc(widget.airportId).collection("location").doc(locationId).collection("Catagorie").snapshots(),

This means widget.airportId is null.

Solution:

You method catageriesList has an used argument airportId which you should be pass as the document path.

Update this line of code:

stream: FirebaseFirestore.instance.collection("Airport").doc(widget.airportId).collection("location").doc(locationId).collection("Catagorie").snapshots(),

to this:

stream: FirebaseFirestore.instance.collection("Airport").doc(airportId).collection("location").doc(locationId).collection("Catagorie").snapshots(),
  • Related