You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter Firebase Firestore iOS端降序查询失效问题求助

Firestore按lastEntranceAt降序查询在iOS模拟器失效的问题

问题说明

编写了一段Flutter/Dart代码,用于从Firestore中按lastEntranceAt字段降序获取用户数据。该代码在Android模拟器中可正常执行,但在iOS模拟器中完全失效;移除orderBy代码行,或者将descending设置为false时,iOS模拟器又能正常工作,且全程未抛出任何异常。最终该问题自行恢复正常。

代码示例

核心查询代码:

_instance
        .collection(FirestoreCol.users.name)
        .orderBy(
          "lastEntranceAt",
          descending: true,
        )
        .limit(limit)
        .get();

测试用补充代码:

return Scaffold(
  appBar: _appBar(),
  body: _body(),
  floatingActionButton: FloatingActionButton(
    onPressed: () {
      FirebaseFirestore.instance
          .collection("users")
          .orderBy("lastEntranceAt", descending: true)
          .limit(20)
          .get()
          .then((value) {
        print(value.docs);
      });
    },
  ),

内容的提问来源于stack exchange,提问作者Ali Kaleş

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 22:52:03