【问题标题】:How can I sort a collection in Firebase with Flutter?如何使用 Flutter 对 Firebase 中的集合进行排序?
【发布时间】:2021-09-27 07:35:34
【问题描述】:

我正在尝试通过在 Firebase 中存储不同用户的高分来使用 Flutter 显示排行榜系统,但我无法弄清楚如何对用户进行排序,因此只有前 10 名出现在集合中低于用户的分数。到目前为止,我得到了它,所以它将它限制在总体得分最高的前十名,但我无法让它只显示得分低于用户的前十名。

// Get Users stream
Stream<List<HighscoreData>> get score {
    return scoreCollection
        .orderBy('score', descending: true,).limit(5)
        .snapshots()
        .map(_scoreListFromSnapshot);
}

【问题讨论】:

    标签: firebase flutter dart


    【解决方案1】:

    让我们试试这个,它对你有用

    Firestore.instance
             .collection("users")
             .orderBy('score', descending: true,).getDocuments()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-04
      • 1970-01-01
      • 2012-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多