firebase - 如何订购具有 2 个字段的 Cloud Firestore 快照?
问题描述
我正在尝试订购具有 2 个字段的云 Firestore 快照。我正在使用颤振/飞镖我有这个错误:NoSuchMethodError: The getter 'lenght' was called on null。接收方:空。尝试调用:长度。另请参阅:https//flutter.dev/docs/testing/errors。
我正在使用 cloud_firestore:^2.2.0
我的代码:
Stream<List<Friend>> getFriends() {
return _db
.collection('profile')
.doc(userId)
.collection('friends')
.orderBy('status', descending: true)
.orderBy('displayName', descending: false)
.snapshots()
.map((snapshot) => snapshot.docs
.map((doc) => Friend.fromJason(doc.data()))
.toList());
}
谢谢您的帮助!