1

I want to implement OR condition in flutter using the multiple where(); method but this returns AND condition.

Following is my code for query

  Future<Stream<QuerySnapshot>> getOrders() async { 
    return FirebaseFirestore.instance
        .collection("Orders")
        .orderBy("timestamp")
        .where("isCredentialUploaded", isEqualTo: true),
        .where("isTransactionDone", isEqualTo: true)
        .snapshots();
  }

But this makes the AND Condition, like this

if(isCredentialUploaded && isTransactionDone)

Is there any way I can get the OR condition in Firebase Firestore?

Result i want:

if(isCredentialUploaded || isTransactionDone)
Sayed Muhammad Idrees
  • 1,245
  • 15
  • 25

1 Answers1

0

In the official documentation of Firebase & Flutter we notice that after using the query we must use get() instead of snapshot().

Try this code:

Future<Stream<QuerySnapshot>> getOrders() async { 
return FirebaseFirestore.instance
    .collection("Orders")
    .orderBy("timestamp")
    .where("isCredentialUploaded", isEqualTo: true),
    .where("isTransactionDone", isEqualTo: true)
    .get();
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Z.Ihab
  • 1
  • 2