flutter - 如何在flutter web中获取downloadurl?
问题描述
我正在研究一个颤动的网络。我编写了uploadtostorage 函数将所选图像上传到firestorage。但是,在将下载地址保存到 Firestore 之前,我不知道如何从上传任务中获取下载地址。这是我的代码。
void uploadToStorage(CurrentUser user) {
final dateTime = DateTime.now();
final uid = user.uid;
final path = '$uid/$dateTime';
uploadImage(onSelected: (file) {
fb
.storage()
.refFromURL('gs://....com')
.child(path)
.put(file)
.future
.then((_) {
// get downloadUrl here
FirebaseFirestore.instance
.collection('users')
.doc(user.uid)
.update({'photo_url': //downloadUrl here});
});
});
}