This query works without the orderBy
. Am I doing this wrong? The start
and end
are set like this:
final startTs = Timestamp.fromMicrosecondsSinceEpoch(
pickedStartDate.microsecondsSinceEpoch,
);
I also included an image with the database value
This is what _buildStream()
returns
FirebaseFirestore.instance
.collection("content")
.where("active", isEqualTo: true)
.where("member", isEqualTo: false)
.where("end", isGreaterThanOrEqualTo: DateTime.now())
.orderBy("start", descending: true)
.snapshots();
Used in a Streambuilder:
StreamBuilder<QuerySnapshot>(
stream: _buildStream(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return Center(child: CircularProgressIndicator());
default:
print(snapshot.data);
final _content = snapshot.data.docs
.map((data) => ContentModel.fromFirestore(data))
.toList();
Error:
flutter: The getter 'docs' was called on null.
flutter: Receiver: null
flutter: Tried calling: docs