Linked Questions

Popular Questions

I am streaming a Document snapshot from Firestore, but snapshot.hasData returns true when there is nothing in the db. This causes my code to fail when try retrieve value out of the snapshot.

How do I fix this?

I tried print out snapshot.Data just got an Documentsnapshot instance. Also thought about provide initial data to the stream, but I do not know how to provide an empty DocumentSnapshot data type.

If I manually insert a record in to firestore, it works fine.


          stream: Firestore.instance.collection('UserDetails').document(widget.uid).snapshots(),
          builder: (context, snapshot){

              widget._err = snapshot.error;
            } else if (snapshot.connectionState == ConnectionState.waiting){
              widget._loadingUserInfo = true;
            } else if (snapshot.hasData){
              nameController.text =['name'];
              ageController.text =['age'];
              introController.text =['intro'];
              widget._loadingUserInfo = false;

I am trying to get user value from Firestore to populate their form if there is a value or user exists.

Now it just fails.

Related Questions