Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter StreamBuilder Called Data 3times

    return Container(
      color: Colors.white,
      child: StreamBuilder<QuerySnapshot>(
          stream: _statusService.getStatus(),
          builder: (context, AsyncSnapshot snapshot) {
            return !snapshot.hasData
                ? CircularProgressIndicator()
                : ListView.builder(
                    itemCount: snapshot.data.docs.length,
                    itemBuilder: (context, index) {
                      DocumentSnapshot movies = snapshot.data.docs[2];
                      return Padding(
                        padding: const EdgeInsets.symmetric(
                          horizontal: 20,
                          vertical: 0,
                        ),
                        child: Padding(
                          padding: const EdgeInsets.symmetric(
                            horizontal: 20,
                            vertical: 0,
                          ),
                          child: Text(
                            "${movies['description']}",
                            style: TextStyle(
                              fontSize: 10,
                              color: Color(0xFF737599),
                            ),
                          ),
                        ),
                      );
                    });
          }),
    );
  }
}

can someone help me i am trying to call some data from firebase but its called 3 times i didn’t find any solution i am waiting for your answers

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I think your data length was 3 but you only show doc2. For the length of doc 3, data is displayed 3 times.

change

itemCount: snapshot.data.docs.length,

To

itemCount: 1,
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading