I first want to determine the length of my collection (i.e. how many documents are in my collection?) and then randomly grab one of the documents and display certain fields in it.
In my Scaffold
I have the following StreamBuilder
so far:
StreamBuilder(
stream: _wordsFoods.snapshots(),
builder: (context, snapshot){
return _buildList(context, snapshot.data.documents);
}
)
_buildList
returns the length of the collection "words":
Widget _buildList(BuildContext context, List<DocumentSnapshot> snapshot) {
return Center(child: Text(snapshot.length.toString()));
}
But how do I now say that I want the (e.g.) second document in my collection? How do I connect it with a query, so I can say I want a certain field within the second document of my collection?