Mr Jax
Mr Jax

Reputation: 1017

Retrieve Subcollection in StreamBuilder (Flutter)

I have a StreamBuilder in my Flutter app which I can use to retrieve data in a document:

class Example extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
  ListView.builder(
  itemCount: aCollection.length,
  itemBuilder: (BuildContext context, int index) {
  return Card(
    child: Row(
      children: <Widget>[
         Text(aCollection[index].data['area']), // Return Area

How can I retrieve data in a Subcollection? Something along the lines of:

aCollection[index]['aDoc']**[aSubCollection]**.data['field']

I'm not sure of the correct syntax - would be great if someone can point me in the right direction!

Database Example Screenshot: img

Upvotes: 0

Views: 1537

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598740

If aCollection[index] is a DocumentSnapshot, then you can get a CollectionReference to a subcollection with aCollection[index].reference.collection("aSubCollection").

Upvotes: 2

Related Questions