颤振 orderBy("time", "asc") 不工作

flutter orderBy("time", "asc") not working

我正在使用嵌套流和未来获取2组数据,但无法按时间对第二组数据进行排序

两种都试过了,还是不行。为什么???

Error: Getter not found: 'Direction'.
                               .orderBy("time", Query.Direction.DESCENDING)
                                                      ^^^^^^^^^

Error: Too many positional arguments: 1 allowed, but 2 found.
Try removing the extra positional arguments.
                               .orderBy("time", 'asc')
                                       ^

完整代码如下:

return StreamBuilder(
      stream: A,
      builder: (context, snapshot) {
        return snapshot.hasData
            ? ListView.builder(
                ...
                  return
                         FutureBuilder(
                           future: FirebaseFirestore.instance
                           .collection("some path here")
                           .orderBy("time", Query.Direction.DESCENDING)
                           .get(),,

                           builder: (context, snapshot2) {
                           if (snapshot2.hasData) {
                                   if (snapshot2.data!=null) {
                                   return DisplayTile(
                                     ...
                                   );
                                   }
                           }
                           return CircularProgressIndicator();
                           }
                           );
                })
            : Container();
      },
    );

orderBy 有 1 个名为 descendingbool 类型的命名参数传递给 order

示例来自 docs

FirebaseFirestore.instance
  .collection('users')
  .orderBy('age', descending: true) // here
  .get()
  .then(...);