I am building a Flutter - Firebase app and I am stuck with advanced display of a Firestore document.
I get the document like so:
Stream<DocumentSnapshot> get theData{
return dataCollection.doc(documentId).snapshots();
}
I then consume the data in a Streambuilder like so:
StreamBuilder<DocumentSnapshot>(stream: theData)
I then get the data like this:
Map<String, dynamic> data= snapshot.data?.data() as Map<String, dynamic>;
To display all fields in the document, I would do something like this:
Column(
children: [
for (var item in data.keys)
Padding(
padding: const EdgeInsets.all(5),
child: ListTile(
tileColor: Colors.grey[300],
title: Text(
item,
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 20),
),
subtitle: Text('${data[item]}'),
),
)
],
)
However, I would like to NOT display some fields based on the keys I specify.
Also, some fields are arrays of image links and would like to render those links as images.