I have some folders in Firebase with some files in them. I want to get the download links of one file from each of the folders and store them for later use. I want to store them in a Map such that each download link will be referenced by a key (the Firebase folder name it was from) in the map.
here is the code:
Map<String,String>? _data; // _data is already populated before calling _editData
void _editData()
{
Reference reference = FirebaseStorage.instance.ref();
_data?.forEach((key, value) async {
String url = await Future.delayed(
const Duration(seconds: 3),
(() => reference.child('$key/$value').getDownloadURL())
);
_data?.update(key, (value) => url)
});
print('data: $_data');
}
But it it seems like this approach is not working because when I print _data, it does not have the url's in it, its not updated. I have to run the function again for the url's to be saved into the map. How can I do this properly?