I need to upload a list of files to Firebase storage, so ive tried the following:
Future uploadImage(List<File>? fileList) async {
List<String> urlList = [];
compressedImageFromDevice?.forEach((file) async {
final ref = await FirebaseStorage.instance
.ref()
.child("img")
.child(id)
.child(time);
final result = await ref.putFile(file);
final String mediaUrl =
await (await result.ref.getDownloadURL()).toString();
urlList.add(mediaUrl);
print(urlList.length()); //List contains an url
});
print(urlList.length()); //Outside of the loop the list keeps empty}
}
Why is the list outside of the loop empty? Sorry but inserting code didn`t worked correctly.