【发布时间】:2021-01-21 03:04:46
【问题描述】:
我需要使用来自 Firestore 的列表,但我不知道如何将我从 Firestore 获得的 Future 列表转换为字符串列表:
Future<List> getListOfProducts() async {
List<String> productsList;
final List<DocumentSnapshot> documents =
(await FirebaseFirestore.instance.collection('products').get()).docs;
productsList = documents
.map((documentSnapshot) => documentSnapshot['productName'] as String)
.toList();
return productsList;
}
我现在应该如何处理 productList ?
【问题讨论】:
标签: flutter dart google-cloud-firestore future