'flutter:getting data from firebase

Stream<QuerySnapshot> readDocument() {
    return _firestore.collection("uploads").snapshots();
  }

This is my stream method that get data from related collection.

body: StreamBuilder<QuerySnapshot>(
          stream: Provider.of<FirebaseServices>(context).readDocument(),
          builder: (context, snapshot) {
            if (!snapshot.hasData) {
              return Center(child: CircularProgressIndicator());
            } else if (snapshot.hasError) {
              return Center(
                child: Text("error"),
              );
            } else {
              QuerySnapshot? data = snapshot.data;
              List<DocumentSnapshot> list = [];
              if (data != null) {
                list = data.docs;
              }
              return ListView.builder(
                itemCount: list.length,
                itemBuilder: (context, index) {
                  return NoteViewWidget();//some widget 
                },
              );
            }
          }),

but when i executed the app,list variable is remaining empty but collection is not i cannot find my mistake.

if i add a document manuel to the uploads collection i can fetch the that data but cant fetch the data that created by app.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source