class _RecipesBodyState extends State<RecipesBody> {
@override
build(BuildContext context) {
var docs = FirestoreService()
.getCollectionData('recipes') // <----------- Here
.then((value) => print(value));
return SafeArea(
child: PageView(children: []),
);
}
}
I do print()
to see the data but when I try to save the data in a variable like this
var docs =
FirestoreService().getCollectionData('recipes').then((value) => value);
print(docs)
I get an Instance of Future<List<dynamic>>
instead the data
the GetCollectionData() have this:
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;
}
I tried to make a list variable and declare its value in the then but it didn't work either.