I have an async function getProducts()
that is supposed to return a Future<List<MyProductTile>>
meant to a be fed to a FutureProvider.
So far, I managed to return a List<Future<MyProductTile>>
instead:
Future<List<MyProductTile>> getProducts(
Stream<DocumentSnapshot> stream) async {
var documentSnapshot = await stream.first;
List<DocumentReference> productsDocRefsList =
List<DocumentReference>.from(documentSnapshot.data['used_products']);
var x = productsDocRefsList
.map((documentReference) => documentReference.get().then(
(documentSnapshot) =>
MyProductTile.fromFirestore(documentSnapshot)))
.toList();
print(x.runtimeType); // List<Future<MyProductTile>>
}
I tried to use Future.wait as suggested in this stackoverflow answer but I didn't succeed.