There are documents in the collection in Firestore. I list these documents on the screen according to the user’s email address. But I want to import each document separately. Each document has an array called title. When I want to get the array of each document separately, I get the following error.
ERROR: type '_JsonQueryDocumentSnapshot' is not a subtype of type 'String'
CODE:
Widget getCustomerRepairLog() {
final user = FirebaseAuth.instance.currentUser!; //better do a null check 1st
late final _repairLogs = FirebaseFirestore.instance.collection('Repair').get();
return FutureBuilder(
future: _repairLogs,
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
List<Widget> items = [];
final data = snapshot.data?.docs;
if (data == null) return Text("got null");
for (final eleman in data) {
if (eleman.data()['email']! == user.email) {
for (final item in eleman.data()['title']) {
items.add(Text("${item}"));
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [Text(eleman)],
);
}
}
// return Row(children: [Icon(Icons.done_all_rounded), ...items]);
// return Column(crossAxisAlignment: CrossAxisAlignment.start,children: [...items]);
// return CircularProgressIndicator();
}
return CircularProgressIndicator();
},
);
}
2
Answers
Try the following code solution:
here I change
elemant
in theText
widget which is a wholeDocumentSnaphot
with its data which isMap<String, dynamic>
:Try the following code: