My async call is returning before list is populated in forEach loop
My async call is returning before list is populated in forEach loop I have a routine which gets a list of filenames from the device, then reads the file(s) to build a list. However, the calling routine always returns with zero items. I print the filenames, so I know they exist, however, it appears that the async is returning before I read the files. I used similar code when making an HTTP call. But, something here is causing the routine to return the list even though it hasn't completed. Perhaps, it is possible that I am calling it at the wrong time? I am calling retrieveItems here: @override void initState() { super.initState(); retrieveItems(); } Eventually I will have a refresh button, but for now I'd simply like the list to populate with the data from the files... Callee Future<List<String>> readHeaderData() async { List<String> l = new List(); List<String> files = await readHeaders(); // Gets filenames files.forEach((filename...
