'How to make sorting by date(TimeStamp) in flutter firebase document list?
I want to sort flutter firebase list by the last date to old date. in currently, Firebase send mixed list. And I want to sort them..
I made this code but I get error in firebase
final Stream<QuerySnapshot> _usersStream = FirebaseFirestore.instance
.collection('CompanyAdvert')
.where('isVerify', isEqualTo: true).orderBy('createdTime', descending: false)
.snapshots();
I get this error in console
Listen for Query(target=Query(CompanyAdvert where isVerify == true order by createdTime, name); limitType=LIMIT_TO_FIRST) failed: Status{code=FAILED_PRECONDITION, description=The query requires an index. You can create it here: https://console.firebase.google.com/v1/r/project/project_one/firestore/indexes?create_composite=ClBwcm9qZWN0cy9jYW4tZ, cause=null}
Solution 1:[1]
open the link on firebase console website and display one Dialog popup for create index.
Just click on Add index button. then refresh the app. It will work :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mohammad mobasher |
