I tried:
FirebaseFirestore.instance
.collection('messages')
.orderBy('sentDate', descending: false)
.snapshots(),
but it didn't work.
CodePudding user response:
If you want to order by the sendDate
of a specific entry in the map you can using dot notation:
.orderBy('167361790.sentDate', descending: false)
If you want to sort on the sentDate
of a dynamically selected map entry, that isn't possible with your current data model, and you'll want to modify your data model to allow the use-case.
For example, if you want to order the messages on the most recent sentDate
, you should add a top-level field to the document latestSentDate
, update that whenever you write to the map, and then sort on that.