Issue
This Content is from Stack Overflow. Question asked by Mat Koffman
I am getting this error in my flutter app:
The getter ‘documents’ isn’t defined for the type ‘QuerySnapshot’.
Try importing the library that defines ‘documents’, correcting the name to the name of an existing getter, or defining a getter or field named ‘documents’.
Here is my code:
getExpenseItems(AsyncSnapshot<QuerySnapshot> snapshot) {
List<ElementTask> listElement = new List(), listElement2;
Map<String, List<ElementTask>> userMap = new Map();
List<String> cardColor = new List();
if (widget.user.uid.isNotEmpty) {
cardColor.clear();
snapshot.data.documents.map<List>((f) {
f.data.forEach((a, b) {
if (b.runtimeType == bool) {
listElement.add(new ElementTask(a, b));
}
if (b.runtimeType == String && a == "color") {
cardColor.add(b);
}
});
listElement2 = new List<ElementTask>.from(listElement);
userMap[f.documentID] = listElement2;
for (int i = 0; i < listElement2.length; i++) {
if (listElement2.elementAt(i).isDone == false) {
userMap.remove(f.documentID);
if (cardColor.isNotEmpty) {
cardColor.removeLast();
}
break;
}
}
if (listElement2.length == 0) {
userMap.remove(f.documentID);
cardColor.removeLast();
}
listElement.clear();
}).toList();
return new List.generate(userMap.length, (int index) {
return new GestureDetector(
onTap: () {
Navigator.of(context).push(
new PageRouteBuilder(
pageBuilder: (_, __, ___) => new DetailPage(
user: widget.user,
i: index,
currentList: userMap,
color: cardColor.elementAt(index),
),
transitionsBuilder:
(context, animation, secondaryAnimation, child) =>
new ScaleTransition(
scale: new Tween<double>(
begin: 1.5,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Interval(
0.50,
1.00,
curve: Curves.linear,
),
),
),
child: ScaleTransition(
scale: Tween<double>(
begin: 0.0,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Interval(
0.00,
0.50,
curve: Curves.linear,
),
),
),
child: child,
),
),
),
);
},
Does anyone know how I can solve this issue?
Solution
documents are now replaced with
QuerySnapshot documents=snapshot.data.docs
This Question was asked in StackOverflow by Mat Koffman and Answered by Ali Hassan It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.