Reputation: 139
i am have some difficulties with saving my list of items inside a function as i do get an error "The method 'getDocuments' isn't defined for the type 'DatabaseReference'." I don't have any clue how to fix it maybe someone could be so kind and explain what I'm doing wrong.
Here is function code snippet
getItemStreamSnapshots() async {
var data = await FirebaseDatabase.instance
.reference()
.child("Book")
.getDocuments();
setState(() {
_allResults = data.documents;
});
searchResultsList();
return "complete";
}
Here's how my DB looks like
Upvotes: 0
Views: 2451
Reputation: 31
DEPRECATED: Calling getDocuments() is deprecated in favor of get().
BREAKING: getDocuments/get has been updated to accept an instance of GetOptions (see below).
NEW: Query methods can now be chained.
NEW: It is now possible to call same-point cursor based queries without throwing (e.g. calling endAt() and then endBefore() will replace the "end" cursor query with the endBefore).
NEW: Added support for the limitToLast query modifier.
link: https://pub.dev/packages/cloud_firestore/changelog#0140
Upvotes: 3
Reputation: 83113
A DatabaseReference
does not have a getDocuments()
method. You should either use the once()
method or the onValue
property, if you want to read the data corresponding to the DatabaseReference
.
You will find more details on how to use the Realtime Database with Flutter in the two following articles: "How to use Firebase realtime database with Flutter" and "How to use Firebase Queries In Flutter".
Upvotes: 1