I started learning dart / flutter on my own initiative.

I have encountered one problem, which I have been trying to solve for the last 3 days.

It is about reading data from the firestore. There are a lot of documents in the firestore. I need a way to read data from multiple query.

I read the data with the streambuilder, and display it with the listview builder.


  stream: database.vehicleStream(user.uid, filters),
  builder: (context, snapshot) {
    if (snapshot.hasData) { ...

Datebase Service:

Stream<List<Vehicle>?> vehicleStream(String uid, List<ScoutFilter> filters) {
vhTest(uid, filters);
final path = APIPath.vehicle();
final reference = FirebaseFirestore.instance
    .where('datetime', isGreaterThan: limitedTime())
    .where('brand', isEqualTo: 'Mercedes-Benz')
    .where('model', isEqualTo: 'SL 350')
    .orderBy('datetime', descending: true)
final snapshots = reference.snapshots();
return snapshots.map((snapshot) => snapshot.docs
      (snapshot) => Vehicle.fromMap(snapshot.data(), snapshot.id),

This works when it comes to one query for "Mercedes-Benz", "SL 350". How do I improve this and have more query for about 30 different vehicles?


.where('brand', isEqualTo: 'Tesla')
.where('model', isEqualTo: 'Model 3')

.where('brand', isEqualTo: 'Audi')
.where('model', isEqualTo: 'Q3')

.where('brand', isEqualTo: 'Renault')
.where('model', isEqualTo: 'Clio')


Solution 1: Roman Jaquez

You should use the whereIn, as in:

.where('brand', whereIn: ['Tesla', 'Audi', 'Renault'])

See this link