I don't know why I can not access the data from flutter while using two "where". can any help me to solve this? what I want is to get all the documents between a period of time Error
The initial orderBy() field '[[FieldPath([dateEnd]), false]][0][0]' has to be the same as the where() field parameter 'FieldPath([date])' when an inequality operator is invoked.
'package:cloud_firestore/src/query.dart':
package:cloud_firestore/src/query.dart:1
Failed assertion: line 677 pos 11: 'field == orders[0][0]'
MY Code
FirebaseFirestore.instance.collection(widget.collectionDbName)
.where('dateEnd', isGreaterThanOrEqualTo: DateTime.now())
.orderBy('dateEnd')
.where('date', isLessThanOrEqualTo: DateTime.now())
.orderBy('date', descending: widget.sortingOrderDesc)
.snapshots(),
You are using two different fields for two where clauses and using <= & >= ranges which are not valid.
As per Firebase documentation You can perform range (<, <=, >, >=) or not equals (!=) comparisons only on a single field.
Valid Examples:
const q1 = query(citiesRef, where("state", ">=", "CA"), where("state", "<=", "IN"));
const q2 = query(citiesRef, where("state", "==", "CA"), where("population", ">", 1000000));