0

I'm trying to make a simples stream from Cloud Firestore. There is content inside of my Firestore data but the Stream doesn't seem to work.
This is how I build the Stream:

body: StreamBuilder(
        stream: Firestore.instance.collection('user_data').document('rCqMQ3oLjBLk6yg6P1oT').collection('Buttons').snapshots(),
        builder: (context, snapshot) {
          if (snapshot.hasError){
            return Container(color: Colors.red);
          }
          if (!snapshot.hasData){
            return Center(child: CircularProgressIndicator());
          }
          if (snapshot.hasData){
            return GridView.count(
              padding: EdgeInsets.all(15),
              crossAxisSpacing: 20.0,
              mainAxisSpacing: 20.0,
              crossAxisCount: 3,
              children: [
                CreateCard("ola"),
                GestureDetector(
                  onTap: () async{
                    print(snapshot.data);
                  },
                  child: Container(
                  color: Colors.black,
                  width: 150,
                  height: 150,
                  child: Icon(Icons.add, color: Colors.white,),
                  ),
                ),
              ],
            );
          }
        }

But it always enters in the ``ìf(!snapshot.hasData)```
Database image: enter image description here

Nilton Schumacher F
  • 814
  • 3
  • 13
  • 43

1 Answers1

2

have you set up your security rules? Sometimes I have this issue without getting an exception from firebase

Try to add this to the security rules for now.

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}

Note: Set up some rules later, this makes your database widely open. https://medium.com/@khreniak/cloud-firestore-security-rules-basics-fac6b6bea18e

laaasBIGL
  • 811
  • 1
  • 7
  • 17