title: Dart List doesnt get updated with forEach loop
body: <p>I am using this <a href="https://github.com/lukasgit/flutter_contacts" rel="nofollow noreferrer">package</a> to retrieve device's contacts. The lib retrieve 427 contacts and I want to loop the whole list so that I can create another list and send it to the back-end. The problem is looping does not work this the function return before looping is completed.</p>
  <p>Here the function I use:</p>
  <pre class="lang-dart prettyprint-override"><code>  Future&lt;QueryResult&gt; uploadContacts() async {
      final List&lt;Contact&gt; rawContacts =
          (await ContactsService.getContacts(withThumbnails: false)).toList();
      List&lt;ContactInput&gt; contactsListInput;
  
      print('contactsListInput length: ${rawContacts.length}');
      
      rawContacts.forEach((contact) {
        print('contact: $contact'); //PRINTED JUST ONCE
  
        //Contact can have more than 1 number. We need them all
        contact.phones.forEach((phone) {
          final contactInput =
              ContactInput(name: contact.displayName, phone: phone.value);
  
          contactsListInput.add(contactInput);
        });
      });
  
      print('contactsListInput length: ${contactsListInput.length}'); //NEVER PRINT ANYTHING
  
      final ContactsListInput input =
          ContactsListInput(contacts: contactsListInput);
  
      final MutationOptions _options = MutationOptions(
          document: SyncContactsMutation().document,
          variables: SyncContactsArguments(input: input).toJson());
  
      return client.mutate(_options);
    }
  </code></pre>
  <p>I have also tried using for loop and the same thing happened.</p>
  <pre class="lang-dart prettyprint-override"><code>    for (int i = 0; i &lt; rawContacts.length; i++) {
        final contact = rawContacts[i];
  
        final contactInput =
        ContactInput(name: contact.displayName, phone: contact.phones.first.value);
  
        contactsListInput.add(contactInput);
      }
      print('contactsListInput length: ${contactsListInput.length}'); //NEVER CALLED
  
  </code></pre>
  <p>And I also tried  Future.forEach</p>
  <pre class="lang-dart prettyprint-override"><code>    await Future.forEach(rawContacts, (contact) async {
        print('contact: $contact');
  
        //Since contact can have more than one number we loop them too.
        await Future.forEach(contact.phones, (phone) async {
          final contactInput =
              ContactInput(name: contact.displayName, phone: phone.value);
  
          contactsListInput.add(contactInput);
        });
      });
  </code></pre>
  <p>How to fix this? Any help will be much appreciated.</p>