I'm trying to get my data in firestore wherein that data is array and output that data in a card. As of now the output I'm getting is "null". What is the best way to get this array of data? I'm using StreamBuilder<QuerySnapshot> to get the data.
Here is my code:
StreamBuilder<QuerySnapshot>(
stream: db.collection('ACTIVITIES').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Column(
children: snapshot.data.documents
.map((doc) => buildItem(doc))
.toList());
} else {
return SizedBox();
}
})
Here is where I try to output the data:
Card buildItem(DocumentSnapshot doc) {
return Card(
elevation: 5,
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Name: ${doc.data['Name_ofUser']}',
style: TextStyle(fontSize: 20),
),
Text(
'Description: ${doc.data['Help_Description']}',
style: TextStyle(fontSize: 20),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
FlatButton(
color: Color(0xFF121A21),
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0),
),
onPressed: () {},
child: Text(
'Respond',
style: TextStyle(color: Colors.white, fontSize: 12),
),
),
SizedBox(
width: 5,
),
FlatButton(
color: Color(0xFF121A21),
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0),
),
onPressed: () {},
child: Text(
'Read',
style: TextStyle(color: Colors.white, fontSize: 12),
),
)
],
),
],
),
),
);
}
This is my database structure:
