class _RecipesBodyState extends State<RecipesBody> {
  @override
  build(BuildContext context) {
    var docs = FirestoreService()
        .getCollectionData('recipes')  // <----------- Here
        .then((value) => print(value));
    return SafeArea(
      child: PageView(children: []),
    );
  }
}
我会print()查看数据,但当我尝试将数据保存在这样的变量中时
    var docs =
        FirestoreService().getCollectionData('recipes').then((value) => value);
    print(docs)
我得到了Future<List<dynamic>>的实例,而不是数据
GetCollectionData()具有以下属性:
Future<List> getCollectionData(String collection) async {
    var data = [];
    QuerySnapshot<Object?> querySnapshot =
        await _db.collection(collection).get();
    List<QueryDocumentSnapshot<Object?>> docs = querySnapshot.docs;
    for (var doc in docs) {
      data.add(doc.data());
    }
    return data;
  }
我试图创建一个列表变量,并在then中声明其值,但也不起作用。