Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
256 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...