【发布时间】:2020-11-26 05:28:21
【问题描述】:
我正在尝试为我的产品缩略图获取图像。但我在这里使用“onComplete”时遇到问题。我也尝试使用“未来”,但它仍然有同样的问题。 这是我的firebase依赖: firebase_core:^0.5.2 firebase_auth:^0.18.3 cloud_firestore:^0.14.3 firebase_database: ^4.3.0 firebase_storage:^5.0.1 firebase_dynamic_links:^0.5.1
Future<List<String>> uploadProductImages(
{Map<int, File> imageList, String docID}) async {
List<String> imagesUrl = List();
try {
for (int s = 0; s < imageList.length; s++) {
Reference storageReference = FirebaseStorage.instance
.ref()
.child(appProducts)
.child(docID)
.child(docID + "$s.jpg");
UploadTask uploadTask = storageReference.putFile(imageList[s]);
Uri downloadUrl = (await uploadTask.onComplete).downloadUrl;
imagesUrl.add(downloadUrl.toString());
}
} on FirebaseException catch (e) {
imagesUrl.add(error);
print(e.message);
}
return imagesUrl;
}
【问题讨论】:
-
能否请您发布您遇到的错误