I'm retrieving some data from FireBase but the following code returns null
var taxes = new List();
Future.wait(providerTax.map((e) async {
var details;
await FirebaseFirestore.instance
.doc(e['tax'].path)
.get()
.then((value) => details = value.data());
taxes.add({
'taxID': e['identifier'],
'taxName': details['taxID'],
'taxRate': details['unitText'],
'taxAmount': store.state.numberWorkedHours *
offer.data()['price'] *
details['value']
});
}));
The same code called differently works and returns the expected result
List tempTax = new List();
for (var tax in providerTax) {
var details;
await FirebaseFirestore.instance
.doc(tax['tax'].path)
.get()
.then((value) => details = value.data());
tempTax.add({
'taxID': tax['identifier'],
'taxName': details['taxID'],
'taxRate': details['unitText'],
'taxAmount': store.state.numberWorkedHours *
offer.data()['price'] *
details['value']
});
Is this related to an incorrect call for futures to execute or is this related to the fact that .map executes lazily?