Map List<Future<Object>> into List<Object>

I have a

List<Future<int>> 

how do I transform it into a

List<int> 

>Solution :

Credit goes to @pskink

This is how you can do it :

  List<int> resultSet = [];

  List<Future<int>> methods = [];

  resultSet = await Future.wait(methods);

You can also do it like this :

  List<int> resultSet = [];

  List<Future<int>> methods = [];

  await Future.wait(methods).then((value) {
    resultSet = value;
  });

  print(resultSet);

More about Future/wait

Leave a Reply