In Firestore API or Firebase Realtime Database API, multiple equalTo() cannot be used together as it is not supported.
However, there are several alternative solutions available to filter data in Flutter API using multiple equalTo():
Firestore.instance.collection('users')
.where('name', isEqualTo: 'John')
.where('age', isEqualTo: 25)
.getDocuments();
Firestore.instance.collection('users')
.where('name', isEqualTo: 'John')
.where('age', isEqualTo: 25)
.getDocuments();
Firestore.instance.collection('users')
.where('name', isEqualTo: 'John')
.where('age', isLessThanOrEqualTo: 30)
.where('city', isEqualTo: 'New York')
.getDocuments();
Firestore.instance.collection('users')
.snapshots()
.map((snapshot) => snapshot.documents.where((document) {
final name = document['name'] as String;
final age = document['age'] as int;
final city = document['city'] as String;
return name == 'John' && age <= 30 && city == 'New York';
}))
.listen((data) => print(data));
All of these solutions have their own advantages and trade-offs, and the optimal approach depends on the specific use case.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-16 20:46:49 +0000
Seen: 10 times
Last updated: May 16 '23
How can I refresh my listView once I have deleted data from the Firebase Realtime Database?
What are the broadcasting patterns for Firebase Realtime?
What are the Cloud Function triggers for both scheduled and on-demand events?
What is the process to modify and retrieve the dictionary type in Swift using Firebase Custom token?