Reputation: 101
I am trying to retrieve data from the first document from a collection on firestore. But, I keep getting the following error: "RangeError (index): Invalid Value: Valid Value Range is Empty: 0"
body: StreamBuilder(
stream: Firestore.instance.collection('users').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return Text('Loading Data...');
return Column(
children: <Widget>[
Text(snapshot.data.documents[0]['email']),
],
);
},
),
Upvotes: 0
Views: 113
Reputation: 80952
Try adding the code inside the else:
if (!snapshot.hasData) return Text('Loading Data...');
else{
return Column(
children: <Widget>[
Text(snapshot.data.documents[0]['email']),
],
);
}
return Text("no Data");
},
Upvotes: 2