Reputation: 139
I'm having a little trouble with returning data into _allResults list. I do get an error data.docs as it shows that "The getter 'docs' isn't defined for the type 'Future'". Maybe someone have any clue what could be the reason for it?
Thank you in advance!
Code snippet
getItemStreamSnapshots() async {
var data = FirebaseFirestore.instance
.collection('Books')
.get();
setState(() {
_allResults = data.docs;
});
searchResultsList();
return "complete";
}
Upvotes: 0
Views: 382
Reputation: 8383
The method get
you are calling is:
Future<QuerySnapshot> get([GetOptions options])
It returns a Future, not a QuerySnapshot
. You can await
for the result since your method is async
:
final data = await FirebaseFirestore.instance.collection('Books').get();
Upvotes: 1