I have a function which returns a list of emails, but in side of it, it builds the list and tries to return it.
How do i return the list wrapped in a future?
Future<List<Email>> getEmails(){
List<Email> emailList = new List<Email>();
//loop to build a set of dummy data
return emailList;
}
Several options:
you can wrap the returned value with new Future<List<Email>>.value(emailList);
you can annotate the function body with the async
keyword:
Future<List<Email>> getEmails() async {
List<Email> emailList = new List<Email>();
//loop to build a set of dummy data
return emailList;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With