从firestore按时间戳降序排列数据



im未能按时间戳降序排列数据,错误一直说定位错误

StreamBuilder( 
stream: Firestore.instance.collection("payments").orderBy("timestamp", "desc").where('participants', arrayContains: userActive).snapshots(),
builder: (context, snapshot){



return Container ( child:ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.documents.length,
padding: EdgeInsets.all(0),
controller: ScrollController(keepScrollOffset: false),
itemBuilder: (context, index){
DocumentSnapshot documentSnapshot = snapshot.data.documents[index].data();

您应该使用以下内容:

orderBy("timestamp", descending : true)

https://github.com/FirebaseExtended/flutterfire/blob/f5a408f0aed529da5602d4562964d60ff50d2a7e/packages/cloud_firestore/cloud_firestore/lib/src/query.dart#L224

最新更新