var capitalValue = value.substring(0,1).toUpperCase() value.substring(1);
if(queryResult.length == 0 && value.length == 1) {
SearchService().searchProduct(value).then((QuerySnapshot docs){
for(int i = 0; i < docs.documents//here error .length; i ) {
queryResult.add(docs.documents//here error [i].data);
}
});
}
else{
tempSearch = [];
queryResult.forEach((element) {
if(element['category'].startsWith(capitalValue)) {
setState(() {
tempSearch.add(element);
});
}
});
}
}
The getter 'documents' isn't defined for the type 'QuerySnapshot<Object?>'.Currently, I'm coding to make a search in the application
CodePudding user response:
I think you are following some old documentation or tutorial. As far as I remember, object of QuerySnapshot has been changed few months ago.
They have simplified the usage by changing documents to docs and document to doc.
So your code should be like this
SearchService().searchProduct(value).then((QuerySnapshot docs){
for(int i = 0; i < docs.docs.length; i ) {
queryResult.add(docs.docs[i].data);
}
});
You can review the changelog here https://gist.github.com/Salakar/a36bd0902d7d0c705696da9318cf4e71